add manual crud commands.

refactor cli interface.
remove file handler.
This commit is contained in:
publicmatt
2024-04-03 07:33:48 -07:00
parent dbdcf5a3ab
commit 0b128ee2e1
15 changed files with 1174 additions and 669 deletions
+65
View File
@@ -0,0 +1,65 @@
use serde::Deserialize;
use std::fmt;
use crate::records::dns_record::DNSRecord;
pub enum Api {
Patch(DNSRecord),
Delete(DNSRecord),
Get(DNSRecord),
List(String),
}
#[derive(Deserialize, Debug)]
pub struct ResponseError {
pub code: String,
pub message: String,
pub fields: Vec<ResponseField>,
}
#[derive(Deserialize, Debug)]
pub struct ResponseField {
#[serde(default)]
pub code: String,
#[serde(default)]
pub message: String,
#[serde(default)]
pub path: String,
#[serde(default)]
#[serde(rename = "pathRelated")]
pub path_related: String,
}
impl fmt::Display for Api {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Api::Patch(record) => write!(
f,
"https://api.godaddy.com/v1/domains/{domain}/records",
domain = record.domain,
),
Api::Delete(record) => write!(
f,
"https://api.godaddy.com/v1/domains/{domain}/records/{record_type}/{name}",
domain = record.domain,
record_type = record.record_type,
name = record.name
),
Api::Get(record) => write!(
f,
"https://api.godaddy.com/v1/domains/{domain}/records/{record_type}/{name}",
domain = record.domain,
record_type = record.record_type,
name = record.name
),
Api::List(domain) => write!(
f,
"https://api.godaddy.com/v1/domains/{domain}/records",
domain = domain,
),
}
}
}