Skip to main content

nautobot_openapi/models/
relationship_request.rs

1/*
2 * API Documentation
3 *
4 * Source of truth and network automation platform
5 *
6 * The version of the OpenAPI document: 3.1.0 (3.1)
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11/// RelationshipRequest : 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 RelationshipRequest {
15    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
16    pub id: Option<uuid::Uuid>,
17    #[serde(rename = "source_type")]
18    pub source_type: String,
19    #[serde(rename = "destination_type")]
20    pub destination_type: String,
21    /// Label of the relationship as displayed to users
22    #[serde(rename = "label")]
23    pub label: String,
24    /// Internal relationship key. Please use underscores rather than dashes in this key.
25    #[serde(rename = "key", skip_serializing_if = "Option::is_none")]
26    pub key: Option<String>,
27    #[serde(rename = "description", skip_serializing_if = "Option::is_none")]
28    pub description: Option<String>,
29    #[serde(rename = "type", skip_serializing_if = "Option::is_none")]
30    pub r#type: Option<crate::models::RelationshipTypeChoices>,
31    #[serde(rename = "required_on", skip_serializing_if = "Option::is_none")]
32    pub required_on: Option<Box<crate::models::BulkWritableRelationshipRequestRequiredOn>>,
33    /// Label for related destination objects, as displayed on the source object.
34    #[serde(rename = "source_label", skip_serializing_if = "Option::is_none")]
35    pub source_label: Option<String>,
36    /// Hide this relationship on the source object.
37    #[serde(rename = "source_hidden", skip_serializing_if = "Option::is_none")]
38    pub source_hidden: Option<bool>,
39    /// Filterset filter matching the applicable source objects of the selected type
40    #[serde(
41        rename = "source_filter",
42        default,
43        with = "::serde_with::rust::double_option",
44        skip_serializing_if = "Option::is_none"
45    )]
46    pub source_filter: Option<Option<serde_json::Value>>,
47    /// Label for related source objects, as displayed on the destination object.
48    #[serde(rename = "destination_label", skip_serializing_if = "Option::is_none")]
49    pub destination_label: Option<String>,
50    /// Hide this relationship on the destination object.
51    #[serde(rename = "destination_hidden", skip_serializing_if = "Option::is_none")]
52    pub destination_hidden: Option<bool>,
53    /// Filterset filter matching the applicable destination objects of the selected type
54    #[serde(
55        rename = "destination_filter",
56        default,
57        with = "::serde_with::rust::double_option",
58        skip_serializing_if = "Option::is_none"
59    )]
60    pub destination_filter: Option<Option<serde_json::Value>>,
61    /// Hide this field from the object's primary information tab. It will appear in the \"Advanced\" tab instead.
62    #[serde(rename = "advanced_ui", skip_serializing_if = "Option::is_none")]
63    pub advanced_ui: Option<bool>,
64}
65
66impl RelationshipRequest {
67    /// 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>)
68    pub fn new(
69        source_type: String,
70        destination_type: String,
71        label: String,
72    ) -> RelationshipRequest {
73        RelationshipRequest {
74            id: None,
75            source_type,
76            destination_type,
77            label,
78            key: None,
79            description: None,
80            r#type: None,
81            required_on: None,
82            source_label: None,
83            source_hidden: None,
84            source_filter: None,
85            destination_label: None,
86            destination_hidden: None,
87            destination_filter: None,
88            advanced_ui: None,
89        }
90    }
91}