use serde::{Deserialize, Serialize};
use validator::Validate;
use crate::v2_1::datatypes::{ComponentType, CustomDataType, StatusInfoType, VariableType};
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub enum AttributeEnumType {
Actual,
Target,
MinSet,
MaxSet,
}
impl Default for AttributeEnumType {
fn default() -> Self {
Self::Actual
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub enum SetVariableStatusEnumType {
Accepted,
Rejected,
UnknownComponent,
UnknownVariable,
NotSupportedAttributeType,
RebootRequired,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Validate)]
#[serde(rename_all = "camelCase")]
pub struct SetVariableDataType {
#[serde(skip_serializing_if = "Option::is_none")]
pub custom_data: Option<CustomDataType>,
#[serde(skip_serializing_if = "Option::is_none")]
pub attribute_type: Option<AttributeEnumType>,
#[validate(length(max = 2500))]
pub attribute_value: String,
pub component: ComponentType,
pub variable: VariableType,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Validate)]
#[serde(rename_all = "camelCase")]
pub struct SetVariableResultType {
#[serde(skip_serializing_if = "Option::is_none")]
pub custom_data: Option<CustomDataType>,
#[serde(skip_serializing_if = "Option::is_none")]
pub attribute_type: Option<AttributeEnumType>,
pub attribute_status: SetVariableStatusEnumType,
#[serde(skip_serializing_if = "Option::is_none")]
pub attribute_status_info: Option<StatusInfoType>,
pub component: ComponentType,
pub variable: VariableType,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Validate)]
#[serde(rename_all = "camelCase")]
pub struct SetVariablesRequest {
#[serde(skip_serializing_if = "Option::is_none")]
pub custom_data: Option<CustomDataType>,
#[validate(length(min = 1), nested)]
pub set_variable_data: Vec<SetVariableDataType>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Validate)]
#[serde(rename_all = "camelCase")]
pub struct SetVariablesResponse {
#[serde(skip_serializing_if = "Option::is_none")]
pub custom_data: Option<CustomDataType>,
#[validate(length(min = 1), nested)]
pub set_variable_result: Vec<SetVariableResultType>,
}