Add more DNS record managment

master
Tait Hoyem 1 year ago
parent 3eab8e3c3e
commit fdac840e69

@ -1,7 +1,7 @@
# `lunanode` # `lunanode`
This is an API to work with the LunaNode's OpenStack-compatible [citation needed] API. This is an API to work with the LunaNode's OpenStack-compatible [citation needed] API.
This crate currently covers only the most basic functionality from the Lunanode API. Currently 33/98 (34%) API calls. This crate currently covers only the most basic functionality from the Lunanode API. Currently 36/98 (37%) API calls.
If you'd like to contribute additional functionality, please feel free to make an MR. If you'd like to contribute additional functionality, please feel free to make an MR.
* VM [8/21] * VM [8/21]
@ -110,15 +110,15 @@ If you'd like to contribute additional functionality, please feel free to make a
* List [ ] * List [ ]
* Add [ ] * Add [ ]
* Remove [ ] * Remove [ ]
* DNS [6/10] * DNS [9/10]
* Zone [2/3] * Zone [3/3]
* List [X] * List [X]
* Add [X] * Add [X]
* Remove [ ] * Remove [X]
* Record [1/3] * Record [3/3]
* List [X] * List [X]
* Add [ ] * Add [X]
* Remove [ ] * Remove [X]
* Dyn [3/4] * Dyn [3/4]
* List [X] * List [X]
* Add [X] * Add [X]
@ -134,6 +134,7 @@ If you'd like to contribute additional functionality, please feel free to make a
## API Keys ## API Keys
Add the `LUNANODE_API_KEY`, `LUNANODE_KEY_ID` and `LUNANODE_API_PARTIALKEY` (the first 64 chars of `LUNANODE_API_KEY`) to your environment variables. Add the `LUNANODE_API_KEY`, `LUNANODE_KEY_ID` and `LUNANODE_API_PARTIALKEY` (the first 64 chars of `LUNANODE_API_KEY`) to your environment variables.
Without these variables set, the tool will not run. You can also specify the keys manually through command-line arguments.
## Usage ## Usage

@ -14,6 +14,7 @@ use crate::{
RecordType, RecordType,
RecordListResponse, RecordListResponse,
RecordAddResponse, RecordAddResponse,
RecordRemoveResponse,
DynListResponse, DynListResponse,
DynAddResponse, DynAddResponse,
DynRemoveResponse, DynRemoveResponse,
@ -45,6 +46,7 @@ use serde::{
Serialize, Serialize,
Deserialize, Deserialize,
}; };
use serde_with::skip_serializing_none;
#[derive(Serialize, Deserialize, Debug, clap::Subcommand)] #[derive(Serialize, Deserialize, Debug, clap::Subcommand)]
/// All possible `ssh-key` subcommands. /// All possible `ssh-key` subcommands.
@ -129,6 +131,10 @@ pub enum ImageSubArgs {
pub enum RecordSubArgs { pub enum RecordSubArgs {
/// List all records in a domain. /// List all records in a domain.
List(RecordListRequest), List(RecordListRequest),
/// Add a new DNS record to a domain.
Add(RecordAddRequest),
/// Remove a DNS record for a domain.
Remove(RecordRemoveRequest),
} }
#[derive(Serialize, Deserialize, Debug, clap::Subcommand)] #[derive(Serialize, Deserialize, Debug, clap::Subcommand)]
@ -286,6 +292,8 @@ impl Args {
Self::Monitor(MonitorSubArgs::Check(MonitorCheckSubArgs::List(monitor_check_list))) => print_req(monitor_check_list)?, Self::Monitor(MonitorSubArgs::Check(MonitorCheckSubArgs::List(monitor_check_list))) => print_req(monitor_check_list)?,
Self::SshKey(SshKeySubArgs::List(ssk_list)) => print_req(ssk_list)?, Self::SshKey(SshKeySubArgs::List(ssk_list)) => print_req(ssk_list)?,
Self::Record(RecordSubArgs::List(rec_list)) => print_req(rec_list)?, Self::Record(RecordSubArgs::List(rec_list)) => print_req(rec_list)?,
Self::Record(RecordSubArgs::Add(add_req)) => print_req(add_req)?,
Self::Record(RecordSubArgs::Remove(rem_req)) => print_req(rem_req)?,
Self::Network(NetworkSubArgs::List(net_list)) => print_req(net_list)?, Self::Network(NetworkSubArgs::List(net_list)) => print_req(net_list)?,
Self::Floating(FloatingSubArgs::List(ip_list)) => print_req(ip_list)?, Self::Floating(FloatingSubArgs::List(ip_list)) => print_req(ip_list)?,
Self::Vm(VmSubArgs::List(vm_list)) => print_req(vm_list)?, Self::Vm(VmSubArgs::List(vm_list)) => print_req(vm_list)?,
@ -497,6 +505,7 @@ pub enum RecordPolicyType {
Region, Region,
} }
#[skip_serializing_none]
#[lunanode_request(response="RecordAddResponse", endpoint="dns2/record-add/")] #[lunanode_request(response="RecordAddResponse", endpoint="dns2/record-add/")]
/// Add a new DNS record to your zone. /// Add a new DNS record to your zone.
pub struct RecordAddRequest { pub struct RecordAddRequest {
@ -523,3 +532,12 @@ pub struct RecordAddRequest {
/// If set, update the existing record with this ID instead of creating a new record. /// If set, update the existing record with this ID instead of creating a new record.
orig_record_id: Option<String>, orig_record_id: Option<String>,
} }
#[lunanode_request(response="RecordRemoveResponse", endpoint="dns2/record-remove/")]
/// Remove a DNS record from a given zone.
pub struct RecordRemoveRequest {
/// The ID of the zone which the DNS record is contained in. This is usually an FQDN like example.com, but we just need the zone ID from Lunanode. See: [`ZoneListResponse`].
zone_id: i32,
/// The ID of the DNS record to remove. See [`RecordListResponse`]
record_id: i32,
}

@ -864,3 +864,8 @@ pub struct ZoneRemoveResponse {}
/// The result of adding a new record. /// The result of adding a new record.
/// See also: [`crate::requests::RecordAddRequest`] /// See also: [`crate::requests::RecordAddRequest`]
pub struct RecordAddResponse {} pub struct RecordAddResponse {}
#[lunanode_response]
/// The result of remove a DNS record.
/// See also: [`crate::requests::RecordRemoveRequest`]
pub struct RecordRemoveResponse {}

Loading…
Cancel
Save