netbox_openapi/models/
custom_field_choice_set_request.rs

1/*
2 * NetBox REST API
3 *
4 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 *
6 * The version of the OpenAPI document: 4.4.2-Docker-3.4.1 (4.4)
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11/// CustomFieldChoiceSetRequest : Extends the built-in ModelSerializer to enforce calling full_clean() on a copy of the associated instance during validation. (DRF does not do this by default; see <https://github.com/encode/django-rest-framework/issues/3144>)
12
13#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)]
14pub struct CustomFieldChoiceSetRequest {
15    #[serde(rename = "name")]
16    pub name: String,
17    #[serde(rename = "description", skip_serializing_if = "Option::is_none")]
18    pub description: Option<String>,
19    /// * `IATA` - IATA (Airport codes) * `ISO_3166` - ISO 3166 (Country codes) * `UN_LOCODE` - UN/LOCODE (Location codes)
20    #[serde(rename = "base_choices", skip_serializing_if = "Option::is_none")]
21    pub base_choices: Option<BaseChoices>,
22    #[serde(rename = "extra_choices")]
23    pub extra_choices: Vec<Vec<serde_json::Value>>,
24    /// Choices are automatically ordered alphabetically
25    #[serde(
26        rename = "order_alphabetically",
27        skip_serializing_if = "Option::is_none"
28    )]
29    pub order_alphabetically: Option<bool>,
30}
31
32impl CustomFieldChoiceSetRequest {
33    /// Extends the built-in ModelSerializer to enforce calling full_clean() on a copy of the associated instance during validation. (DRF does not do this by default; see <https://github.com/encode/django-rest-framework/issues/3144>)
34    pub fn new(
35        name: String,
36        extra_choices: Vec<Vec<serde_json::Value>>,
37    ) -> CustomFieldChoiceSetRequest {
38        CustomFieldChoiceSetRequest {
39            name,
40            description: None,
41            base_choices: None,
42            extra_choices,
43            order_alphabetically: None,
44        }
45    }
46}
47
48/// * `IATA` - IATA (Airport codes) * `ISO_3166` - ISO 3166 (Country codes) * `UN_LOCODE` - UN/LOCODE (Location codes)
49#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
50pub enum BaseChoices {
51    #[serde(rename = "IATA")]
52    Iata,
53    #[serde(rename = "ISO_3166")]
54    Iso3166,
55    #[serde(rename = "UN_LOCODE")]
56    UnLocode,
57}
58
59impl Default for BaseChoices {
60    fn default() -> BaseChoices {
61        Self::Iata
62    }
63}