Skip to main content

netbox_openapi/models/
owner.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.6.2 (4.6)
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11/// Owner : 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 Owner {
15    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
16    pub id: Option<i32>,
17    #[serde(rename = "url", skip_serializing_if = "Option::is_none")]
18    pub url: Option<String>,
19    #[serde(rename = "display_url", skip_serializing_if = "Option::is_none")]
20    pub display_url: Option<String>,
21    #[serde(rename = "display", skip_serializing_if = "Option::is_none")]
22    pub display: Option<String>,
23    #[serde(rename = "name")]
24    pub name: String,
25    #[serde(rename = "group", deserialize_with = "Option::deserialize")]
26    pub group: Option<Box<crate::models::BriefOwnerGroup>>,
27    #[serde(rename = "description", skip_serializing_if = "Option::is_none")]
28    pub description: Option<String>,
29    #[serde(rename = "user_groups", skip_serializing_if = "Option::is_none")]
30    pub user_groups: Option<Vec<crate::models::Group>>,
31    #[serde(rename = "users", skip_serializing_if = "Option::is_none")]
32    pub users: Option<Vec<crate::models::User>>,
33}
34
35impl Owner {
36    /// 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>)
37    pub fn new(name: String, group: Option<crate::models::BriefOwnerGroup>) -> Owner {
38        Owner {
39            id: None,
40            url: None,
41            display_url: None,
42            display: None,
43            name,
44            group: if let Some(x) = group {
45                Some(Box::new(x))
46            } else {
47                None
48            },
49            description: None,
50            user_groups: None,
51            users: None,
52        }
53    }
54}