Switch UUIDs from uuid::Uuid to String to preserve dashes.

master
Tait Hoyem 2 years ago
parent f3f5d5d558
commit cf349fc694

@ -18,6 +18,9 @@ use crate::{
MonitorCheckListResponse,
MonitorCheckTypesResponse,
MonitorContactListResponse,
VmStartResponse,
VmStopResponse,
VmRebootResponse,
},
types::{
LNError,
@ -93,6 +96,12 @@ pub enum RecordSubArgs {
pub enum VmSubArgs {
/// List all VMs on my account.
List(VMListRequest),
/// Restart a VM, given an ID.
Reboot(VmRebootRequest),
/// Stop a VM, given an ID.
Stop(VmStopRequest),
/// Turn on a VM, given an ID.
Start(VmStartRequest),
}
#[derive(Serialize, Deserialize, Debug, clap::Subcommand)]
#[serde(untagged)]
@ -210,6 +219,9 @@ impl Args {
Self::Network(NetworkSubArgs::List(net_list)) => print_req(net_list)?,
Self::Floating(FloatingSubArgs::List(ip_list)) => print_req(ip_list)?,
Self::Vm(VmSubArgs::List(vm_list)) => print_req(vm_list)?,
Self::Vm(VmSubArgs::Start(vm_to_start)) => print_req(vm_to_start)?,
Self::Vm(VmSubArgs::Stop(vm_to_stop)) => print_req(vm_to_stop)?,
Self::Vm(VmSubArgs::Reboot(vm_to_reboot)) => print_req(vm_to_reboot)?,
Self::Volume(VolumeSubArgs::List(vol_list)) => print_req(vol_list)?,
Self::Image(ImageSubArgs::List(image_list)) => print_req(image_list)?,
Self::Billing(BillingSubArgs::Credit(billing_credit)) => print_req(billing_credit)?,
@ -291,3 +303,18 @@ pub struct MonitorContactListRequest {}
pub struct EmailUserListRequest {
domain_id: i32,
}
#[lunanode_request(response="VmStartResponse", endpoint="vm/start/")]
pub struct VmStartRequest {
vm_id: String,
}
#[lunanode_request(response="VmStopResponse", endpoint="vm/stop/")]
pub struct VmStopRequest {
vm_id: String,
}
#[lunanode_request(response="VmRebootResponse", endpoint="vm/reboot/")]
pub struct VmRebootRequest {
vm_id: String,
}

@ -19,9 +19,8 @@ use uuid;
#[derive(Serialize, Deserialize, PartialEq, Debug)]
/// Defines a VM (used for requests using the VM section)
pub struct VirtualMachine {
#[serde_as(as="DisplayFromStr")]
/// the UUID of the VM
vm_id: uuid::Uuid, // should be UUIDv4
vm_id: String, // should be UUIDv4
/// the name of the VM set by the user
name: String, // the name set by the user
#[serde_as(as="DisplayFromStr")]
@ -76,7 +75,7 @@ enum AttachmentType {
#[serde_as]
#[derive(Serialize, Deserialize, Debug)]
struct FloatingIp {
attached_id: Option<uuid::Uuid>,
attached_id: Option<String>,
attached_name: Option<String>,
attached_type: AttachmentType,
hostname: String,
@ -121,7 +120,7 @@ pub struct VMInfoExtra {
vcpu: i32,
#[serde_as(as="DisplayFromStr")]
/// UUIDv4 of the VM
vm_id: uuid::Uuid,
vm_id: String,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(untagged)]
@ -279,7 +278,7 @@ pub struct Volume {
id: i32,
#[serde_as(as="DisplayFromStr")]
/// the UUID for the volume
identification: uuid::Uuid,
identification: String,
/// the name set by the user
name: String,
/// The region where the volume is located.
@ -604,3 +603,12 @@ pub struct EmailUserListResponse {
#[serde(flatten)]
users: std::collections::HashMap<String, EmailUser>,
}
#[lunanode_response]
pub struct VmStartResponse {}
#[lunanode_response]
pub struct VmStopResponse {}
#[lunanode_response]
pub struct VmRebootResponse {}

Loading…
Cancel
Save