netbox_openapi/models/
subscription.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/// Subscription : 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 Subscription {
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", skip_serializing_if = "Option::is_none")]
20    pub display: Option<String>,
21    #[serde(rename = "object_type")]
22    pub object_type: String,
23    #[serde(rename = "object_id")]
24    pub object_id: i64,
25    #[serde(
26        rename = "object",
27        default,
28        with = "::serde_with::rust::double_option",
29        skip_serializing_if = "Option::is_none"
30    )]
31    pub object: Option<Option<serde_json::Value>>,
32    #[serde(rename = "user")]
33    pub user: Box<crate::models::BriefUser>,
34    #[serde(rename = "created", skip_serializing_if = "Option::is_none")]
35    pub created: Option<String>,
36}
37
38impl Subscription {
39    /// 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>)
40    pub fn new(
41        object_type: String,
42        object_id: i64,
43        user: crate::models::BriefUser,
44    ) -> Subscription {
45        Subscription {
46            id: None,
47            url: None,
48            display: None,
49            object_type,
50            object_id,
51            object: None,
52            user: Box::new(user),
53            created: None,
54        }
55    }
56}