Skip to main content

nautobot_openapi/models/
object_permission_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/// ObjectPermissionRequest : 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 ObjectPermissionRequest {
15    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
16    pub id: Option<uuid::Uuid>,
17    #[serde(rename = "object_types")]
18    pub object_types: Vec<String>,
19    #[serde(rename = "name")]
20    pub name: String,
21    #[serde(rename = "description", skip_serializing_if = "Option::is_none")]
22    pub description: Option<String>,
23    #[serde(rename = "enabled", skip_serializing_if = "Option::is_none")]
24    pub enabled: Option<bool>,
25    /// The list of actions granted by this permission
26    #[serde(rename = "actions", deserialize_with = "Option::deserialize")]
27    pub actions: Option<serde_json::Value>,
28    /// Queryset filter matching the applicable objects of the selected type(s)
29    #[serde(
30        rename = "constraints",
31        default,
32        with = "::serde_with::rust::double_option",
33        skip_serializing_if = "Option::is_none"
34    )]
35    pub constraints: Option<Option<serde_json::Value>>,
36    #[serde(rename = "groups", skip_serializing_if = "Option::is_none")]
37    pub groups: Option<Vec<crate::models::ApprovalWorkflowStageResponseApprovalWorkflowStage>>,
38    #[serde(rename = "users", skip_serializing_if = "Option::is_none")]
39    pub users: Option<Vec<crate::models::ApprovalWorkflowStageResponseApprovalWorkflowStage>>,
40}
41
42impl ObjectPermissionRequest {
43    /// 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>)
44    pub fn new(
45        object_types: Vec<String>,
46        name: String,
47        actions: Option<serde_json::Value>,
48    ) -> ObjectPermissionRequest {
49        ObjectPermissionRequest {
50            id: None,
51            object_types,
52            name,
53            description: None,
54            enabled: None,
55            actions,
56            constraints: None,
57            groups: None,
58            users: None,
59        }
60    }
61}