diff --git a/src/requests.rs b/src/requests.rs index 7b1b490..8efbb78 100644 --- a/src/requests.rs +++ b/src/requests.rs @@ -10,7 +10,9 @@ use crate::{ ZoneListResponse, ZoneAddResponse, ZoneRemoveResponse, + RecordType, RecordListResponse, + RecordAddResponse, DynListResponse, DynAddResponse, DynRemoveResponse, @@ -404,3 +406,33 @@ pub struct ZoneAddRequest { pub struct ZoneRemoveRequest { zone_id: i32, } + +#[derive(Serialize, Deserialize, Debug, Clone, Eq, Hash, PartialEq)] +#[serde(rename_all="lowercase")] +pub enum RecordPolicyType { + r#None, + LatLong, + Region, +} + +#[lunanode_request(response="RecordAddResponse", endpoint="dns2/record-add/")] +pub struct RecordAddRequest { + zone_id: i32, + name: String, + data: String, + ttl: i32, + r#type: RecordType, + /// The priority for certain record types, like MX and SRV. + aux: Option, + policy: Option, + /// The record weight (this is used for balancing or non-round-robin DNS failover). + weight: Option, + /// latitude if policy is `latlong` + latitude: Option, + /// longitude if policy is `latlong` + longitude: Option, + /// The ID of a monitor check (see `monitor check list`), this record will be disabled if the check fails. + monitor_id: Option, + /// If set, update the existing record with this ID instead of creating a new record. + orig_record_id: Option, +} diff --git a/src/responses.rs b/src/responses.rs index ea588f7..4261721 100644 --- a/src/responses.rs +++ b/src/responses.rs @@ -379,9 +379,9 @@ pub struct ZoneListResponse { zones: std::collections::HashMap, } -#[derive(Serialize, Deserialize, Debug)] +#[derive(Serialize, Deserialize, Debug, Clone, Eq, PartialEq, Hash)] #[serde(rename="UPPERCASE")] -enum RecordType { +pub enum RecordType { A, AAAA, CNAME, @@ -652,3 +652,6 @@ pub struct ZoneAddResponse {} #[lunanode_response] pub struct ZoneRemoveResponse {} + +#[lunanode_response] +pub struct RecordAddResponse {}