Skip to main content

netbox_openapi/models/
user_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.6.2 (4.6)
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11/// UserRequest : 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 UserRequest {
15    /// Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.
16    #[serde(rename = "username")]
17    pub username: String,
18    #[serde(rename = "password")]
19    pub password: String,
20    #[serde(rename = "first_name", skip_serializing_if = "Option::is_none")]
21    pub first_name: Option<String>,
22    #[serde(rename = "last_name", skip_serializing_if = "Option::is_none")]
23    pub last_name: Option<String>,
24    #[serde(rename = "email", skip_serializing_if = "Option::is_none")]
25    pub email: Option<String>,
26    /// Designates whether this user should be treated as active. Unselect this instead of deleting accounts.
27    #[serde(rename = "is_active", skip_serializing_if = "Option::is_none")]
28    pub is_active: Option<bool>,
29    #[serde(rename = "date_joined", skip_serializing_if = "Option::is_none")]
30    pub date_joined: Option<String>,
31    #[serde(
32        rename = "last_login",
33        default,
34        with = "::serde_with::rust::double_option",
35        skip_serializing_if = "Option::is_none"
36    )]
37    pub last_login: Option<Option<String>>,
38    #[serde(rename = "groups", skip_serializing_if = "Option::is_none")]
39    pub groups: Option<Vec<i32>>,
40    #[serde(rename = "permissions", skip_serializing_if = "Option::is_none")]
41    pub permissions: Option<Vec<i32>>,
42}
43
44impl UserRequest {
45    /// 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>)
46    pub fn new(username: String, password: String) -> UserRequest {
47        UserRequest {
48            username,
49            password,
50            first_name: None,
51            last_name: None,
52            email: None,
53            is_active: None,
54            date_joined: None,
55            last_login: None,
56            groups: None,
57            permissions: None,
58        }
59    }
60}