1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
// DO NOT EDIT
// This file was generated by Stone

#![allow(
    clippy::too_many_arguments,
    clippy::large_enum_variant,
    clippy::doc_markdown,
)]

pub type GroupExternalId = String;
pub type GroupId = String;
pub type MemberExternalId = String;
pub type ResellerId = String;
pub type TeamMemberId = String;

/// The group type determines how a group is managed.
#[derive(Debug)]
pub enum GroupManagementType {
    /// A group which is managed by selected users.
    UserManaged,
    /// A group which is managed by team admins only.
    CompanyManaged,
    /// A group which is managed automatically by Dropbox.
    SystemManaged,
    /// Catch-all used for unrecognized values returned from the server. Encountering this value
    /// typically indicates that this SDK version is out of date.
    Other,
}

impl<'de> ::serde::de::Deserialize<'de> for GroupManagementType {
    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        // union deserializer
        use serde::de::{self, MapAccess, Visitor};
        struct EnumVisitor;
        impl<'de> Visitor<'de> for EnumVisitor {
            type Value = GroupManagementType;
            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
                f.write_str("a GroupManagementType structure")
            }
            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
                let tag: &str = match map.next_key()? {
                    Some(".tag") => map.next_value()?,
                    _ => return Err(de::Error::missing_field(".tag"))
                };
                match tag {
                    "user_managed" => {
                        crate::eat_json_fields(&mut map)?;
                        Ok(GroupManagementType::UserManaged)
                    }
                    "company_managed" => {
                        crate::eat_json_fields(&mut map)?;
                        Ok(GroupManagementType::CompanyManaged)
                    }
                    "system_managed" => {
                        crate::eat_json_fields(&mut map)?;
                        Ok(GroupManagementType::SystemManaged)
                    }
                    _ => {
                        crate::eat_json_fields(&mut map)?;
                        Ok(GroupManagementType::Other)
                    }
                }
            }
        }
        const VARIANTS: &[&str] = &["user_managed",
                                    "company_managed",
                                    "system_managed",
                                    "other"];
        deserializer.deserialize_struct("GroupManagementType", VARIANTS, EnumVisitor)
    }
}

impl ::serde::ser::Serialize for GroupManagementType {
    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        // union serializer
        use serde::ser::SerializeStruct;
        match *self {
            GroupManagementType::UserManaged => {
                // unit
                let mut s = serializer.serialize_struct("GroupManagementType", 1)?;
                s.serialize_field(".tag", "user_managed")?;
                s.end()
            }
            GroupManagementType::CompanyManaged => {
                // unit
                let mut s = serializer.serialize_struct("GroupManagementType", 1)?;
                s.serialize_field(".tag", "company_managed")?;
                s.end()
            }
            GroupManagementType::SystemManaged => {
                // unit
                let mut s = serializer.serialize_struct("GroupManagementType", 1)?;
                s.serialize_field(".tag", "system_managed")?;
                s.end()
            }
            GroupManagementType::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
        }
    }
}

/// Information about a group.
#[derive(Debug)]
pub struct GroupSummary {
    pub group_name: String,
    pub group_id: GroupId,
    /// Who is allowed to manage the group.
    pub group_management_type: GroupManagementType,
    /// External ID of group. This is an arbitrary ID that an admin can attach to a group.
    pub group_external_id: Option<GroupExternalId>,
    /// The number of members in the group.
    pub member_count: Option<u32>,
}

impl GroupSummary {
    pub fn new(
        group_name: String,
        group_id: GroupId,
        group_management_type: GroupManagementType,
    ) -> Self {
        GroupSummary {
            group_name,
            group_id,
            group_management_type,
            group_external_id: None,
            member_count: None,
        }
    }

    pub fn with_group_external_id(mut self, value: Option<GroupExternalId>) -> Self {
        self.group_external_id = value;
        self
    }

    pub fn with_member_count(mut self, value: Option<u32>) -> Self {
        self.member_count = value;
        self
    }

}

const GROUP_SUMMARY_FIELDS: &[&str] = &["group_name",
                                        "group_id",
                                        "group_management_type",
                                        "group_external_id",
                                        "member_count"];
impl GroupSummary {
    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
        map: V,
    ) -> Result<GroupSummary, V::Error> {
        Self::internal_deserialize_opt(map, false).map(Option::unwrap)
    }

    pub(crate) fn internal_deserialize_opt<'de, V: ::serde::de::MapAccess<'de>>(
        mut map: V,
        optional: bool,
    ) -> Result<Option<GroupSummary>, V::Error> {
        let mut field_group_name = None;
        let mut field_group_id = None;
        let mut field_group_management_type = None;
        let mut field_group_external_id = None;
        let mut field_member_count = None;
        let mut nothing = true;
        while let Some(key) = map.next_key::<&str>()? {
            nothing = false;
            match key {
                "group_name" => {
                    if field_group_name.is_some() {
                        return Err(::serde::de::Error::duplicate_field("group_name"));
                    }
                    field_group_name = Some(map.next_value()?);
                }
                "group_id" => {
                    if field_group_id.is_some() {
                        return Err(::serde::de::Error::duplicate_field("group_id"));
                    }
                    field_group_id = Some(map.next_value()?);
                }
                "group_management_type" => {
                    if field_group_management_type.is_some() {
                        return Err(::serde::de::Error::duplicate_field("group_management_type"));
                    }
                    field_group_management_type = Some(map.next_value()?);
                }
                "group_external_id" => {
                    if field_group_external_id.is_some() {
                        return Err(::serde::de::Error::duplicate_field("group_external_id"));
                    }
                    field_group_external_id = Some(map.next_value()?);
                }
                "member_count" => {
                    if field_member_count.is_some() {
                        return Err(::serde::de::Error::duplicate_field("member_count"));
                    }
                    field_member_count = Some(map.next_value()?);
                }
                _ => {
                    // unknown field allowed and ignored
                    map.next_value::<::serde_json::Value>()?;
                }
            }
        }
        if optional && nothing {
            return Ok(None);
        }
        let result = GroupSummary {
            group_name: field_group_name.ok_or_else(|| ::serde::de::Error::missing_field("group_name"))?,
            group_id: field_group_id.ok_or_else(|| ::serde::de::Error::missing_field("group_id"))?,
            group_management_type: field_group_management_type.ok_or_else(|| ::serde::de::Error::missing_field("group_management_type"))?,
            group_external_id: field_group_external_id,
            member_count: field_member_count,
        };
        Ok(Some(result))
    }

    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
        &self,
        s: &mut S::SerializeStruct,
    ) -> Result<(), S::Error> {
        use serde::ser::SerializeStruct;
        s.serialize_field("group_name", &self.group_name)?;
        s.serialize_field("group_id", &self.group_id)?;
        s.serialize_field("group_management_type", &self.group_management_type)?;
        s.serialize_field("group_external_id", &self.group_external_id)?;
        s.serialize_field("member_count", &self.member_count)
    }
}

impl<'de> ::serde::de::Deserialize<'de> for GroupSummary {
    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        // struct deserializer
        use serde::de::{MapAccess, Visitor};
        struct StructVisitor;
        impl<'de> Visitor<'de> for StructVisitor {
            type Value = GroupSummary;
            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
                f.write_str("a GroupSummary struct")
            }
            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
                GroupSummary::internal_deserialize(map)
            }
        }
        deserializer.deserialize_struct("GroupSummary", GROUP_SUMMARY_FIELDS, StructVisitor)
    }
}

impl ::serde::ser::Serialize for GroupSummary {
    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        // struct serializer
        use serde::ser::SerializeStruct;
        let mut s = serializer.serialize_struct("GroupSummary", 5)?;
        self.internal_serialize::<S>(&mut s)?;
        s.end()
    }
}

/// The group type determines how a group is created and managed.
#[derive(Debug)]
pub enum GroupType {
    /// A group to which team members are automatically added. Applicable to [team
    /// folders](https://www.dropbox.com/help/986) only.
    Team,
    /// A group is created and managed by a user.
    UserManaged,
    /// Catch-all used for unrecognized values returned from the server. Encountering this value
    /// typically indicates that this SDK version is out of date.
    Other,
}

impl<'de> ::serde::de::Deserialize<'de> for GroupType {
    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        // union deserializer
        use serde::de::{self, MapAccess, Visitor};
        struct EnumVisitor;
        impl<'de> Visitor<'de> for EnumVisitor {
            type Value = GroupType;
            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
                f.write_str("a GroupType structure")
            }
            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
                let tag: &str = match map.next_key()? {
                    Some(".tag") => map.next_value()?,
                    _ => return Err(de::Error::missing_field(".tag"))
                };
                match tag {
                    "team" => {
                        crate::eat_json_fields(&mut map)?;
                        Ok(GroupType::Team)
                    }
                    "user_managed" => {
                        crate::eat_json_fields(&mut map)?;
                        Ok(GroupType::UserManaged)
                    }
                    _ => {
                        crate::eat_json_fields(&mut map)?;
                        Ok(GroupType::Other)
                    }
                }
            }
        }
        const VARIANTS: &[&str] = &["team",
                                    "user_managed",
                                    "other"];
        deserializer.deserialize_struct("GroupType", VARIANTS, EnumVisitor)
    }
}

impl ::serde::ser::Serialize for GroupType {
    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        // union serializer
        use serde::ser::SerializeStruct;
        match *self {
            GroupType::Team => {
                // unit
                let mut s = serializer.serialize_struct("GroupType", 1)?;
                s.serialize_field(".tag", "team")?;
                s.end()
            }
            GroupType::UserManaged => {
                // unit
                let mut s = serializer.serialize_struct("GroupType", 1)?;
                s.serialize_field(".tag", "user_managed")?;
                s.end()
            }
            GroupType::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
        }
    }
}

/// The type of the space limit imposed on a team member.
#[derive(Debug)]
pub enum MemberSpaceLimitType {
    /// The team member does not have imposed space limit.
    Off,
    /// The team member has soft imposed space limit - the limit is used for display and for
    /// notifications.
    AlertOnly,
    /// The team member has hard imposed space limit - Dropbox file sync will stop after the limit
    /// is reached.
    StopSync,
    /// Catch-all used for unrecognized values returned from the server. Encountering this value
    /// typically indicates that this SDK version is out of date.
    Other,
}

impl<'de> ::serde::de::Deserialize<'de> for MemberSpaceLimitType {
    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        // union deserializer
        use serde::de::{self, MapAccess, Visitor};
        struct EnumVisitor;
        impl<'de> Visitor<'de> for EnumVisitor {
            type Value = MemberSpaceLimitType;
            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
                f.write_str("a MemberSpaceLimitType structure")
            }
            fn visit_map<V: MapAccess<'de>>(self, mut map: V) -> Result<Self::Value, V::Error> {
                let tag: &str = match map.next_key()? {
                    Some(".tag") => map.next_value()?,
                    _ => return Err(de::Error::missing_field(".tag"))
                };
                match tag {
                    "off" => {
                        crate::eat_json_fields(&mut map)?;
                        Ok(MemberSpaceLimitType::Off)
                    }
                    "alert_only" => {
                        crate::eat_json_fields(&mut map)?;
                        Ok(MemberSpaceLimitType::AlertOnly)
                    }
                    "stop_sync" => {
                        crate::eat_json_fields(&mut map)?;
                        Ok(MemberSpaceLimitType::StopSync)
                    }
                    _ => {
                        crate::eat_json_fields(&mut map)?;
                        Ok(MemberSpaceLimitType::Other)
                    }
                }
            }
        }
        const VARIANTS: &[&str] = &["off",
                                    "alert_only",
                                    "stop_sync",
                                    "other"];
        deserializer.deserialize_struct("MemberSpaceLimitType", VARIANTS, EnumVisitor)
    }
}

impl ::serde::ser::Serialize for MemberSpaceLimitType {
    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        // union serializer
        use serde::ser::SerializeStruct;
        match *self {
            MemberSpaceLimitType::Off => {
                // unit
                let mut s = serializer.serialize_struct("MemberSpaceLimitType", 1)?;
                s.serialize_field(".tag", "off")?;
                s.end()
            }
            MemberSpaceLimitType::AlertOnly => {
                // unit
                let mut s = serializer.serialize_struct("MemberSpaceLimitType", 1)?;
                s.serialize_field(".tag", "alert_only")?;
                s.end()
            }
            MemberSpaceLimitType::StopSync => {
                // unit
                let mut s = serializer.serialize_struct("MemberSpaceLimitType", 1)?;
                s.serialize_field(".tag", "stop_sync")?;
                s.end()
            }
            MemberSpaceLimitType::Other => Err(::serde::ser::Error::custom("cannot serialize 'Other' variant"))
        }
    }
}

/// Time range.
#[derive(Debug)]
pub struct TimeRange {
    /// Optional starting time (inclusive).
    pub start_time: Option<super::common::DropboxTimestamp>,
    /// Optional ending time (exclusive).
    pub end_time: Option<super::common::DropboxTimestamp>,
}

impl Default for TimeRange {
    fn default() -> Self {
        TimeRange {
            start_time: None,
            end_time: None,
        }
    }
}

const TIME_RANGE_FIELDS: &[&str] = &["start_time",
                                     "end_time"];
impl TimeRange {
    // no _opt deserializer
    pub(crate) fn internal_deserialize<'de, V: ::serde::de::MapAccess<'de>>(
        mut map: V,
    ) -> Result<TimeRange, V::Error> {
        let mut field_start_time = None;
        let mut field_end_time = None;
        while let Some(key) = map.next_key::<&str>()? {
            match key {
                "start_time" => {
                    if field_start_time.is_some() {
                        return Err(::serde::de::Error::duplicate_field("start_time"));
                    }
                    field_start_time = Some(map.next_value()?);
                }
                "end_time" => {
                    if field_end_time.is_some() {
                        return Err(::serde::de::Error::duplicate_field("end_time"));
                    }
                    field_end_time = Some(map.next_value()?);
                }
                _ => {
                    // unknown field allowed and ignored
                    map.next_value::<::serde_json::Value>()?;
                }
            }
        }
        let result = TimeRange {
            start_time: field_start_time,
            end_time: field_end_time,
        };
        Ok(result)
    }

    pub(crate) fn internal_serialize<S: ::serde::ser::Serializer>(
        &self,
        s: &mut S::SerializeStruct,
    ) -> Result<(), S::Error> {
        use serde::ser::SerializeStruct;
        s.serialize_field("start_time", &self.start_time)?;
        s.serialize_field("end_time", &self.end_time)
    }
}

impl<'de> ::serde::de::Deserialize<'de> for TimeRange {
    fn deserialize<D: ::serde::de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
        // struct deserializer
        use serde::de::{MapAccess, Visitor};
        struct StructVisitor;
        impl<'de> Visitor<'de> for StructVisitor {
            type Value = TimeRange;
            fn expecting(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
                f.write_str("a TimeRange struct")
            }
            fn visit_map<V: MapAccess<'de>>(self, map: V) -> Result<Self::Value, V::Error> {
                TimeRange::internal_deserialize(map)
            }
        }
        deserializer.deserialize_struct("TimeRange", TIME_RANGE_FIELDS, StructVisitor)
    }
}

impl ::serde::ser::Serialize for TimeRange {
    fn serialize<S: ::serde::ser::Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
        // struct serializer
        use serde::ser::SerializeStruct;
        let mut s = serializer.serialize_struct("TimeRange", 2)?;
        self.internal_serialize::<S>(&mut s)?;
        s.end()
    }
}