aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHimbeerserverDE <himbeerserverde@gmail.com>2022-10-22 17:23:02 +0200
committerHimbeerserverDE <himbeerserverde@gmail.com>2022-10-22 17:23:37 +0200
commit54845f4e30bfd80e6f68fbad439fdfd1062842b0 (patch)
tree0715c0bc80e3231a40601dec55904305fcdf68bf
parentcc26d8e46e9b4ddf8f79b837b70aa5c35bac77a7 (diff)
add nameserver.updateRecord
no response to this call exists so we don't need to implement it
-rw-r--r--src/call/nameserver.rs89
-rw-r--r--src/response/nameserver.rs6
2 files changed, 95 insertions, 0 deletions
diff --git a/src/call/nameserver.rs b/src/call/nameserver.rs
index 2783545..fa26d41 100644
--- a/src/call/nameserver.rs
+++ b/src/call/nameserver.rs
@@ -1,4 +1,5 @@
use super::Call;
+use crate::response::nameserver::UrlRdrType;
use crate::{Error, Result};
use std::collections::BTreeMap;
@@ -161,3 +162,91 @@ impl Call for RecordInfo {
&[1000]
}
}
+
+/// Update the records with the specified IDs.
+/// Any `None` variants will remain unchanged.
+#[derive(Clone, Debug)]
+pub struct RecordUpdate {
+ pub ids: Vec<i32>,
+ pub name: Option<String>,
+ pub record_type: Option<RecordType>,
+ pub content: Option<String>,
+ pub ttl: Option<i32>,
+ pub priority: Option<i32>,
+ pub url_rdr_type: Option<UrlRdrType>,
+ pub url_rdr_title: Option<String>,
+ pub url_rdr_desc: Option<String>,
+ pub url_rdr_keywords: Option<String>,
+ pub url_rdr_favicon: Option<String>,
+ pub url_append: Option<bool>,
+ 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) -> &'static str {
+ "nameserver.updateRecord"
+ }
+
+ fn expected(&self) -> &'static [i32] {
+ &[1000]
+ }
+}
diff --git a/src/response/nameserver.rs b/src/response/nameserver.rs
index 38f03b0..a6ab226 100644
--- a/src/response/nameserver.rs
+++ b/src/response/nameserver.rs
@@ -151,6 +151,12 @@ impl TryFrom<String> for UrlRdrType {
}
}
+impl From<UrlRdrType> for xmlrpc::Value {
+ fn from(url_rdr_type: UrlRdrType) -> Self {
+ url_rdr_type.to_string().into()
+ }
+}
+
/// A nameserver record. Contains DNS information as well as INWX metadata.
#[derive(Clone, Debug)]
pub struct Record {