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