use super::floating_ip::FloatingIp;
use super::Action;
use crate::method::{Create, Get, List};
use crate::request::{FloatingIpActionRequest, FloatingIpRequest};
use crate::STATIC_URL_ERROR;
const FLOATING_IP_ACTIONS_SEGMENT: &str = "actions";
impl FloatingIpRequest<Get, FloatingIp> {
pub fn actions(mut self) -> FloatingIpActionRequest<List, Vec<Action>> {
self.url_mut()
.path_segments_mut()
.expect(STATIC_URL_ERROR)
.push(FLOATING_IP_ACTIONS_SEGMENT);
self.transmute()
}
pub fn action(mut self, id: usize) -> FloatingIpActionRequest<Get, Action> {
self.url_mut()
.path_segments_mut()
.expect(STATIC_URL_ERROR)
.push(FLOATING_IP_ACTIONS_SEGMENT)
.push(&id.to_string());
self.transmute()
}
pub fn unassign(mut self) -> FloatingIpActionRequest<Create, Action> {
self.url_mut()
.path_segments_mut()
.expect(STATIC_URL_ERROR)
.push(FLOATING_IP_ACTIONS_SEGMENT);
self.set_body(json!({
"type": "unassign",
}));
self.transmute()
}
pub fn assign(mut self, id: usize) -> FloatingIpActionRequest<Create, Action> {
self.url_mut()
.path_segments_mut()
.expect(STATIC_URL_ERROR)
.push(FLOATING_IP_ACTIONS_SEGMENT);
self.set_body(json!({
"type": "assign",
"droplet_id": id,
}));
self.transmute()
}
}