Skip to main content

jacquard_api/network_slices/slice/
get_sync_summary.rs

1// @generated by jacquard-lexicon. DO NOT EDIT.
2//
3// Lexicon: network.slices.slice.getSyncSummary
4//
5// This file was automatically generated from Lexicon schemas.
6// Any manual changes will be overwritten on the next regeneration.
7
8#[allow(unused_imports)]
9use alloc::collections::BTreeMap;
10
11#[allow(unused_imports)]
12use core::marker::PhantomData;
13use jacquard_common::CowStr;
14
15#[allow(unused_imports)]
16use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
17use jacquard_derive::{IntoStatic, lexicon};
18use jacquard_lexicon::lexicon::LexiconDoc;
19use jacquard_lexicon::schema::LexiconSchema;
20
21#[allow(unused_imports)]
22use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
23use serde::{Serialize, Deserialize};
24use crate::network_slices::slice::get_sync_summary;
25
26#[lexicon]
27#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
28#[serde(rename_all = "camelCase")]
29pub struct CollectionSummary<'a> {
30    #[serde(borrow)]
31    pub collection: CowStr<'a>,
32    pub estimated_repos: i64,
33    pub is_external: bool,
34}
35
36
37#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
38#[serde(rename_all = "camelCase")]
39pub struct GetSyncSummary<'a> {
40    #[serde(skip_serializing_if = "Option::is_none")]
41    #[serde(borrow)]
42    pub collections: Option<Vec<CowStr<'a>>>,
43    #[serde(skip_serializing_if = "Option::is_none")]
44    #[serde(borrow)]
45    pub external_collections: Option<Vec<CowStr<'a>>>,
46    #[serde(skip_serializing_if = "Option::is_none")]
47    #[serde(borrow)]
48    pub repos: Option<Vec<CowStr<'a>>>,
49    #[serde(borrow)]
50    pub slice: CowStr<'a>,
51}
52
53
54#[lexicon]
55#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
56#[serde(rename_all = "camelCase")]
57pub struct GetSyncSummaryOutput<'a> {
58    ///The actual limit applied (user-specified or default)
59    pub applied_limit: i64,
60    ///Number of repositories after applying limit
61    pub capped_repos: i64,
62    #[serde(borrow)]
63    pub collections_summary: Vec<get_sync_summary::CollectionSummary<'a>>,
64    ///Total number of repositories that would be synced
65    pub total_repos: i64,
66    ///Whether the sync would be limited by maxRepos
67    pub would_be_capped: bool,
68}
69
70impl<'a> LexiconSchema for CollectionSummary<'a> {
71    fn nsid() -> &'static str {
72        "network.slices.slice.getSyncSummary"
73    }
74    fn def_name() -> &'static str {
75        "collectionSummary"
76    }
77    fn lexicon_doc() -> LexiconDoc<'static> {
78        lexicon_doc_network_slices_slice_getSyncSummary()
79    }
80    fn validate(&self) -> Result<(), ConstraintError> {
81        Ok(())
82    }
83}
84
85/// Response type for network.slices.slice.getSyncSummary
86pub struct GetSyncSummaryResponse;
87impl jacquard_common::xrpc::XrpcResp for GetSyncSummaryResponse {
88    const NSID: &'static str = "network.slices.slice.getSyncSummary";
89    const ENCODING: &'static str = "application/json";
90    type Output<'de> = GetSyncSummaryOutput<'de>;
91    type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
92}
93
94impl<'a> jacquard_common::xrpc::XrpcRequest for GetSyncSummary<'a> {
95    const NSID: &'static str = "network.slices.slice.getSyncSummary";
96    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
97    type Response = GetSyncSummaryResponse;
98}
99
100/// Endpoint type for network.slices.slice.getSyncSummary
101pub struct GetSyncSummaryRequest;
102impl jacquard_common::xrpc::XrpcEndpoint for GetSyncSummaryRequest {
103    const PATH: &'static str = "/xrpc/network.slices.slice.getSyncSummary";
104    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
105    type Request<'de> = GetSyncSummary<'de>;
106    type Response = GetSyncSummaryResponse;
107}
108
109pub mod collection_summary_state {
110
111    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
112    #[allow(unused)]
113    use ::core::marker::PhantomData;
114    mod sealed {
115        pub trait Sealed {}
116    }
117    /// State trait tracking which required fields have been set
118    pub trait State: sealed::Sealed {
119        type Collection;
120        type EstimatedRepos;
121        type IsExternal;
122    }
123    /// Empty state - all required fields are unset
124    pub struct Empty(());
125    impl sealed::Sealed for Empty {}
126    impl State for Empty {
127        type Collection = Unset;
128        type EstimatedRepos = Unset;
129        type IsExternal = Unset;
130    }
131    ///State transition - sets the `collection` field to Set
132    pub struct SetCollection<S: State = Empty>(PhantomData<fn() -> S>);
133    impl<S: State> sealed::Sealed for SetCollection<S> {}
134    impl<S: State> State for SetCollection<S> {
135        type Collection = Set<members::collection>;
136        type EstimatedRepos = S::EstimatedRepos;
137        type IsExternal = S::IsExternal;
138    }
139    ///State transition - sets the `estimated_repos` field to Set
140    pub struct SetEstimatedRepos<S: State = Empty>(PhantomData<fn() -> S>);
141    impl<S: State> sealed::Sealed for SetEstimatedRepos<S> {}
142    impl<S: State> State for SetEstimatedRepos<S> {
143        type Collection = S::Collection;
144        type EstimatedRepos = Set<members::estimated_repos>;
145        type IsExternal = S::IsExternal;
146    }
147    ///State transition - sets the `is_external` field to Set
148    pub struct SetIsExternal<S: State = Empty>(PhantomData<fn() -> S>);
149    impl<S: State> sealed::Sealed for SetIsExternal<S> {}
150    impl<S: State> State for SetIsExternal<S> {
151        type Collection = S::Collection;
152        type EstimatedRepos = S::EstimatedRepos;
153        type IsExternal = Set<members::is_external>;
154    }
155    /// Marker types for field names
156    #[allow(non_camel_case_types)]
157    pub mod members {
158        ///Marker type for the `collection` field
159        pub struct collection(());
160        ///Marker type for the `estimated_repos` field
161        pub struct estimated_repos(());
162        ///Marker type for the `is_external` field
163        pub struct is_external(());
164    }
165}
166
167/// Builder for constructing an instance of this type
168pub struct CollectionSummaryBuilder<'a, S: collection_summary_state::State> {
169    _state: PhantomData<fn() -> S>,
170    _fields: (Option<CowStr<'a>>, Option<i64>, Option<bool>),
171    _lifetime: PhantomData<&'a ()>,
172}
173
174impl<'a> CollectionSummary<'a> {
175    /// Create a new builder for this type
176    pub fn new() -> CollectionSummaryBuilder<'a, collection_summary_state::Empty> {
177        CollectionSummaryBuilder::new()
178    }
179}
180
181impl<'a> CollectionSummaryBuilder<'a, collection_summary_state::Empty> {
182    /// Create a new builder with all fields unset
183    pub fn new() -> Self {
184        CollectionSummaryBuilder {
185            _state: PhantomData,
186            _fields: (None, None, None),
187            _lifetime: PhantomData,
188        }
189    }
190}
191
192impl<'a, S> CollectionSummaryBuilder<'a, S>
193where
194    S: collection_summary_state::State,
195    S::Collection: collection_summary_state::IsUnset,
196{
197    /// Set the `collection` field (required)
198    pub fn collection(
199        mut self,
200        value: impl Into<CowStr<'a>>,
201    ) -> CollectionSummaryBuilder<'a, collection_summary_state::SetCollection<S>> {
202        self._fields.0 = Option::Some(value.into());
203        CollectionSummaryBuilder {
204            _state: PhantomData,
205            _fields: self._fields,
206            _lifetime: PhantomData,
207        }
208    }
209}
210
211impl<'a, S> CollectionSummaryBuilder<'a, S>
212where
213    S: collection_summary_state::State,
214    S::EstimatedRepos: collection_summary_state::IsUnset,
215{
216    /// Set the `estimatedRepos` field (required)
217    pub fn estimated_repos(
218        mut self,
219        value: impl Into<i64>,
220    ) -> CollectionSummaryBuilder<'a, collection_summary_state::SetEstimatedRepos<S>> {
221        self._fields.1 = Option::Some(value.into());
222        CollectionSummaryBuilder {
223            _state: PhantomData,
224            _fields: self._fields,
225            _lifetime: PhantomData,
226        }
227    }
228}
229
230impl<'a, S> CollectionSummaryBuilder<'a, S>
231where
232    S: collection_summary_state::State,
233    S::IsExternal: collection_summary_state::IsUnset,
234{
235    /// Set the `isExternal` field (required)
236    pub fn is_external(
237        mut self,
238        value: impl Into<bool>,
239    ) -> CollectionSummaryBuilder<'a, collection_summary_state::SetIsExternal<S>> {
240        self._fields.2 = Option::Some(value.into());
241        CollectionSummaryBuilder {
242            _state: PhantomData,
243            _fields: self._fields,
244            _lifetime: PhantomData,
245        }
246    }
247}
248
249impl<'a, S> CollectionSummaryBuilder<'a, S>
250where
251    S: collection_summary_state::State,
252    S::Collection: collection_summary_state::IsSet,
253    S::EstimatedRepos: collection_summary_state::IsSet,
254    S::IsExternal: collection_summary_state::IsSet,
255{
256    /// Build the final struct
257    pub fn build(self) -> CollectionSummary<'a> {
258        CollectionSummary {
259            collection: self._fields.0.unwrap(),
260            estimated_repos: self._fields.1.unwrap(),
261            is_external: self._fields.2.unwrap(),
262            extra_data: Default::default(),
263        }
264    }
265    /// Build the final struct with custom extra_data
266    pub fn build_with_data(
267        self,
268        extra_data: BTreeMap<
269            jacquard_common::deps::smol_str::SmolStr,
270            jacquard_common::types::value::Data<'a>,
271        >,
272    ) -> CollectionSummary<'a> {
273        CollectionSummary {
274            collection: self._fields.0.unwrap(),
275            estimated_repos: self._fields.1.unwrap(),
276            is_external: self._fields.2.unwrap(),
277            extra_data: Some(extra_data),
278        }
279    }
280}
281
282fn lexicon_doc_network_slices_slice_getSyncSummary() -> LexiconDoc<'static> {
283    #[allow(unused_imports)]
284    use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
285    use jacquard_lexicon::lexicon::*;
286    use alloc::collections::BTreeMap;
287    LexiconDoc {
288        lexicon: Lexicon::Lexicon1,
289        id: CowStr::new_static("network.slices.slice.getSyncSummary"),
290        defs: {
291            let mut map = BTreeMap::new();
292            map.insert(
293                SmolStr::new_static("collectionSummary"),
294                LexUserType::Object(LexObject {
295                    required: Some(
296                        vec![
297                            SmolStr::new_static("collection"),
298                            SmolStr::new_static("estimatedRepos"),
299                            SmolStr::new_static("isExternal")
300                        ],
301                    ),
302                    properties: {
303                        #[allow(unused_mut)]
304                        let mut map = BTreeMap::new();
305                        map.insert(
306                            SmolStr::new_static("collection"),
307                            LexObjectProperty::String(LexString { ..Default::default() }),
308                        );
309                        map.insert(
310                            SmolStr::new_static("estimatedRepos"),
311                            LexObjectProperty::Integer(LexInteger {
312                                ..Default::default()
313                            }),
314                        );
315                        map.insert(
316                            SmolStr::new_static("isExternal"),
317                            LexObjectProperty::Boolean(LexBoolean {
318                                ..Default::default()
319                            }),
320                        );
321                        map
322                    },
323                    ..Default::default()
324                }),
325            );
326            map.insert(
327                SmolStr::new_static("main"),
328                LexUserType::XrpcQuery(LexXrpcQuery {
329                    parameters: Some(
330                        LexXrpcQueryParameter::Params(LexXrpcParameters {
331                            required: Some(vec![SmolStr::new_static("slice")]),
332                            properties: {
333                                #[allow(unused_mut)]
334                                let mut map = BTreeMap::new();
335                                map.insert(
336                                    SmolStr::new_static("collections"),
337                                    LexXrpcParametersProperty::Array(LexPrimitiveArray {
338                                        items: LexPrimitiveArrayItem::String(LexString {
339                                            ..Default::default()
340                                        }),
341                                        ..Default::default()
342                                    }),
343                                );
344                                map.insert(
345                                    SmolStr::new_static("externalCollections"),
346                                    LexXrpcParametersProperty::Array(LexPrimitiveArray {
347                                        items: LexPrimitiveArrayItem::String(LexString {
348                                            ..Default::default()
349                                        }),
350                                        ..Default::default()
351                                    }),
352                                );
353                                map.insert(
354                                    SmolStr::new_static("repos"),
355                                    LexXrpcParametersProperty::Array(LexPrimitiveArray {
356                                        items: LexPrimitiveArrayItem::String(LexString {
357                                            ..Default::default()
358                                        }),
359                                        ..Default::default()
360                                    }),
361                                );
362                                map.insert(
363                                    SmolStr::new_static("slice"),
364                                    LexXrpcParametersProperty::String(LexString {
365                                        description: Some(
366                                            CowStr::new_static("URI of the slice to sync"),
367                                        ),
368                                        ..Default::default()
369                                    }),
370                                );
371                                map
372                            },
373                            ..Default::default()
374                        }),
375                    ),
376                    ..Default::default()
377                }),
378            );
379            map
380        },
381        ..Default::default()
382    }
383}
384
385pub mod get_sync_summary_state {
386
387    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
388    #[allow(unused)]
389    use ::core::marker::PhantomData;
390    mod sealed {
391        pub trait Sealed {}
392    }
393    /// State trait tracking which required fields have been set
394    pub trait State: sealed::Sealed {
395        type Slice;
396    }
397    /// Empty state - all required fields are unset
398    pub struct Empty(());
399    impl sealed::Sealed for Empty {}
400    impl State for Empty {
401        type Slice = Unset;
402    }
403    ///State transition - sets the `slice` field to Set
404    pub struct SetSlice<S: State = Empty>(PhantomData<fn() -> S>);
405    impl<S: State> sealed::Sealed for SetSlice<S> {}
406    impl<S: State> State for SetSlice<S> {
407        type Slice = Set<members::slice>;
408    }
409    /// Marker types for field names
410    #[allow(non_camel_case_types)]
411    pub mod members {
412        ///Marker type for the `slice` field
413        pub struct slice(());
414    }
415}
416
417/// Builder for constructing an instance of this type
418pub struct GetSyncSummaryBuilder<'a, S: get_sync_summary_state::State> {
419    _state: PhantomData<fn() -> S>,
420    _fields: (
421        Option<Vec<CowStr<'a>>>,
422        Option<Vec<CowStr<'a>>>,
423        Option<Vec<CowStr<'a>>>,
424        Option<CowStr<'a>>,
425    ),
426    _lifetime: PhantomData<&'a ()>,
427}
428
429impl<'a> GetSyncSummary<'a> {
430    /// Create a new builder for this type
431    pub fn new() -> GetSyncSummaryBuilder<'a, get_sync_summary_state::Empty> {
432        GetSyncSummaryBuilder::new()
433    }
434}
435
436impl<'a> GetSyncSummaryBuilder<'a, get_sync_summary_state::Empty> {
437    /// Create a new builder with all fields unset
438    pub fn new() -> Self {
439        GetSyncSummaryBuilder {
440            _state: PhantomData,
441            _fields: (None, None, None, None),
442            _lifetime: PhantomData,
443        }
444    }
445}
446
447impl<'a, S: get_sync_summary_state::State> GetSyncSummaryBuilder<'a, S> {
448    /// Set the `collections` field (optional)
449    pub fn collections(mut self, value: impl Into<Option<Vec<CowStr<'a>>>>) -> Self {
450        self._fields.0 = value.into();
451        self
452    }
453    /// Set the `collections` field to an Option value (optional)
454    pub fn maybe_collections(mut self, value: Option<Vec<CowStr<'a>>>) -> Self {
455        self._fields.0 = value;
456        self
457    }
458}
459
460impl<'a, S: get_sync_summary_state::State> GetSyncSummaryBuilder<'a, S> {
461    /// Set the `externalCollections` field (optional)
462    pub fn external_collections(
463        mut self,
464        value: impl Into<Option<Vec<CowStr<'a>>>>,
465    ) -> Self {
466        self._fields.1 = value.into();
467        self
468    }
469    /// Set the `externalCollections` field to an Option value (optional)
470    pub fn maybe_external_collections(mut self, value: Option<Vec<CowStr<'a>>>) -> Self {
471        self._fields.1 = value;
472        self
473    }
474}
475
476impl<'a, S: get_sync_summary_state::State> GetSyncSummaryBuilder<'a, S> {
477    /// Set the `repos` field (optional)
478    pub fn repos(mut self, value: impl Into<Option<Vec<CowStr<'a>>>>) -> Self {
479        self._fields.2 = value.into();
480        self
481    }
482    /// Set the `repos` field to an Option value (optional)
483    pub fn maybe_repos(mut self, value: Option<Vec<CowStr<'a>>>) -> Self {
484        self._fields.2 = value;
485        self
486    }
487}
488
489impl<'a, S> GetSyncSummaryBuilder<'a, S>
490where
491    S: get_sync_summary_state::State,
492    S::Slice: get_sync_summary_state::IsUnset,
493{
494    /// Set the `slice` field (required)
495    pub fn slice(
496        mut self,
497        value: impl Into<CowStr<'a>>,
498    ) -> GetSyncSummaryBuilder<'a, get_sync_summary_state::SetSlice<S>> {
499        self._fields.3 = Option::Some(value.into());
500        GetSyncSummaryBuilder {
501            _state: PhantomData,
502            _fields: self._fields,
503            _lifetime: PhantomData,
504        }
505    }
506}
507
508impl<'a, S> GetSyncSummaryBuilder<'a, S>
509where
510    S: get_sync_summary_state::State,
511    S::Slice: get_sync_summary_state::IsSet,
512{
513    /// Build the final struct
514    pub fn build(self) -> GetSyncSummary<'a> {
515        GetSyncSummary {
516            collections: self._fields.0,
517            external_collections: self._fields.1,
518            repos: self._fields.2,
519            slice: self._fields.3.unwrap(),
520        }
521    }
522}