aboutsummaryrefslogtreecommitdiff
path: root/src/call/nameserver.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/call/nameserver.rs')
-rw-r--r--src/call/nameserver.rs133
1 files changed, 21 insertions, 112 deletions
diff --git a/src/call/nameserver.rs b/src/call/nameserver.rs
index c490a31..3b59646 100644
--- a/src/call/nameserver.rs
+++ b/src/call/nameserver.rs
@@ -1,146 +1,55 @@
use super::Call;
-use crate::common::nameserver::{RecordType, UrlRdrType};
-use std::collections::BTreeMap;
+use serde_derive::{Deserialize, Serialize};
/// Optional search constraints to find nameserver records
/// the account has access to.
-#[derive(Clone, Debug)]
+#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct RecordInfo {
+ #[serde(rename = "domain")]
pub domain_name: Option<String>,
+ #[serde(rename = "roId")]
pub domain_id: Option<i32>,
+ #[serde(rename = "recordId")]
pub record_id: Option<i32>,
- pub record_type: Option<RecordType>,
+ #[serde(rename = "type")]
+ pub record_type: Option<String>,
pub name: Option<String>,
pub content: Option<String>,
pub ttl: Option<i32>,
+ #[serde(rename = "prio")]
pub priority: Option<i32>,
}
-impl From<RecordInfo> for xmlrpc::Value {
- fn from(info: RecordInfo) -> Self {
- let mut map = BTreeMap::new();
-
- if let Some(domain_name) = info.domain_name {
- map.insert("domain".into(), domain_name.into());
- }
-
- if let Some(domain_id) = info.domain_id {
- map.insert("roId".into(), domain_id.into());
- }
-
- if let Some(record_id) = info.record_id {
- map.insert("recordId".into(), record_id.into());
- }
-
- if let Some(record_type) = info.record_type {
- map.insert("type".into(), record_type.into());
- }
-
- if let Some(content) = info.content {
- map.insert("content".into(), content.into());
- }
-
- if let Some(ttl) = info.ttl {
- map.insert("ttl".into(), ttl.into());
- }
-
- if let Some(priority) = info.priority {
- map.insert("prio".into(), priority.into());
- }
-
- xmlrpc::Value::Struct(map)
- }
-}
-
-impl Call for RecordInfo {
- fn method_name(&self) -> String {
- String::from("nameserver.info")
- }
-
- fn expected(&self) -> Vec<i32> {
- vec![1000]
- }
-}
-
/// Update the records with the specified IDs.
/// Any `None` variants will remain unchanged.
-#[derive(Clone, Debug)]
+#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct RecordUpdate {
+ #[serde(rename = "id")]
pub ids: Vec<i32>,
pub name: Option<String>,
- pub record_type: Option<RecordType>,
+ #[serde(rename = "type")]
+ pub record_type: Option<String>,
pub content: Option<String>,
pub ttl: Option<i32>,
+ #[serde(rename = "prio")]
pub priority: Option<i32>,
- pub url_rdr_type: Option<UrlRdrType>,
+ #[serde(rename = "urlRedirectType")]
+ pub url_rdr_type: Option<String>,
+ #[serde(rename = "urlRedirectTitle")]
pub url_rdr_title: Option<String>,
+ #[serde(rename = "urlRedirectDescription")]
pub url_rdr_desc: Option<String>,
+ #[serde(rename = "urlRedirectKeywords")]
pub url_rdr_keywords: Option<String>,
+ #[serde(rename = "urlRedirectFavIcon")]
pub url_rdr_favicon: Option<String>,
+ #[serde(rename = "urlAppend")]
pub url_append: Option<bool>,
+ #[serde(rename = "testing")]
pub testing_mode: bool,
}
-impl From<RecordUpdate> for xmlrpc::Value {
- fn from(update: RecordUpdate) -> Self {
- let mut map = BTreeMap::new();
-
- map.insert(
- "id".into(),
- xmlrpc::Value::Array(update.ids.iter().map(|v| xmlrpc::Value::from(*v)).collect()),
- );
-
- if let Some(name) = update.name {
- map.insert("name".into(), name.into());
- }
-
- if let Some(record_type) = update.record_type {
- map.insert("type".into(), record_type.into());
- }
-
- if let Some(content) = update.content {
- map.insert("content".into(), content.into());
- }
-
- if let Some(ttl) = update.ttl {
- map.insert("ttl".into(), ttl.into());
- }
-
- if let Some(priority) = update.priority {
- map.insert("prio".into(), priority.into());
- }
-
- if let Some(url_rdr_type) = update.url_rdr_type {
- map.insert("urlRedirectType".into(), url_rdr_type.into());
- }
-
- if let Some(url_rdr_title) = update.url_rdr_title {
- map.insert("urlRedirectTitle".into(), url_rdr_title.into());
- }
-
- if let Some(url_rdr_desc) = update.url_rdr_desc {
- map.insert("urlRedirectDescription".into(), url_rdr_desc.into());
- }
-
- if let Some(url_rdr_keywords) = update.url_rdr_keywords {
- map.insert("urlRedirectKeywords".into(), url_rdr_keywords.into());
- }
-
- if let Some(url_rdr_favicon) = update.url_rdr_favicon {
- map.insert("urlRedirectFavIcon".into(), url_rdr_favicon.into());
- }
-
- if let Some(url_append) = update.url_append {
- map.insert("urlAppend".into(), url_append.into());
- }
-
- map.insert("testing".into(), update.testing_mode.into());
-
- xmlrpc::Value::Struct(map)
- }
-}
-
impl Call for RecordUpdate {
fn method_name(&self) -> String {
String::from("nameserver.updateRecord")