linode_api/endpoints/v4/linode_instances/
disk_create.rs1use serde::{Deserialize, Serialize};
2use serde_json::{Map, Value};
3
4use crate::objects::v4::linode_instances::Disk;
5
6#[derive(Deserialize, Serialize, Debug, Clone, Default)]
8pub struct RequestBodyWithImage {
9 pub size: usize,
10 pub image: String,
11 pub root_pass: String,
12 #[serde(skip_serializing_if = "Option::is_none")]
13 pub authorized_keys: Option<Vec<String>>,
14 #[serde(flatten, skip_serializing_if = "Map::is_empty")]
15 pub _extra: Map<String, Value>,
16}
17
18wrapping_macro::wrapping! {
20 #[derive(Deserialize, Serialize, Debug, Clone)]
21 pub struct ResponseBody(pub Disk);
22}
23
24#[cfg(test)]
25mod tests {
26 use super::*;
27
28 use crate::objects::v4::linode_instances::DiskStatus;
29
30 #[test]
31 fn test_de_response_body() {
32 match serde_json::from_str::<ResponseBody>(include_str!(
33 "../../../../tests/response_body_files/linode_instances/disk_create.json"
34 )) {
35 Ok(json) => {
36 assert_eq!(json.status, DiskStatus::Ready);
37 }
38 x => panic!("{x:?}"),
39 }
40 }
41}