netbox_openapi/models/
writable_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/// WritableCustomFieldChoiceSetRequest : 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 WritableCustomFieldChoiceSetRequest {
15    #[serde(rename = "name")]
16    pub name: String,
17    #[serde(rename = "description", skip_serializing_if = "Option::is_none")]
18    pub description: Option<String>,
19    /// Base set of predefined choices (optional)  * `IATA` - IATA (Airport codes) * `ISO_3166` - ISO 3166 (Country codes) * `UN_LOCODE` - UN/LOCODE (Location codes)
20    #[serde(
21        rename = "base_choices",
22        default,
23        with = "::serde_with::rust::double_option",
24        skip_serializing_if = "Option::is_none"
25    )]
26    pub base_choices: Option<Option<BaseChoices>>,
27    #[serde(rename = "extra_choices")]
28    pub extra_choices: Vec<Vec<serde_json::Value>>,
29    /// Choices are automatically ordered alphabetically
30    #[serde(
31        rename = "order_alphabetically",
32        skip_serializing_if = "Option::is_none"
33    )]
34    pub order_alphabetically: Option<bool>,
35}
36
37impl WritableCustomFieldChoiceSetRequest {
38    /// 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>)
39    pub fn new(
40        name: String,
41        extra_choices: Vec<Vec<serde_json::Value>>,
42    ) -> WritableCustomFieldChoiceSetRequest {
43        WritableCustomFieldChoiceSetRequest {
44            name,
45            description: None,
46            base_choices: None,
47            extra_choices,
48            order_alphabetically: None,
49        }
50    }
51}
52
53/// Base set of predefined choices (optional)  * `IATA` - IATA (Airport codes) * `ISO_3166` - ISO 3166 (Country codes) * `UN_LOCODE` - UN/LOCODE (Location codes)
54#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
55pub enum BaseChoices {
56    #[serde(rename = "IATA")]
57    Iata,
58    #[serde(rename = "ISO_3166")]
59    Iso3166,
60    #[serde(rename = "UN_LOCODE")]
61    UnLocode,
62    #[serde(rename = "")]
63    Empty,
64    #[serde(rename = "null")]
65    Null,
66}
67
68impl Default for BaseChoices {
69    fn default() -> BaseChoices {
70        Self::Iata
71    }
72}