You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
639 lines
22 KiB
639 lines
22 KiB
//! All possible requests which can be made to the Lunanode API.
|
|
|
|
use crate::{
|
|
responses::{
|
|
VmListResponse,
|
|
BillingCreditResponse,
|
|
ImageListResponse,
|
|
VolumeListResponse,
|
|
FloatingIpListResponse,
|
|
NetworkListResponse,
|
|
ZoneListResponse,
|
|
ZoneAddResponse,
|
|
ZoneRemoveResponse,
|
|
RecordType,
|
|
RecordListResponse,
|
|
RecordAddResponse,
|
|
RecordRemoveResponse,
|
|
DynListResponse,
|
|
DynAddResponse,
|
|
DynRemoveResponse,
|
|
SshKeyResponse,
|
|
PlanListResponse,
|
|
RegionListResponse,
|
|
EmailUsageResponse,
|
|
EmailDomainListResponse,
|
|
EmailDomainAddResponse,
|
|
EmailDomainRemoveResponse,
|
|
EmailDomainDkimSetResponse,
|
|
EmailDomainDkimUnsetResponse,
|
|
EmailUserListResponse,
|
|
EmailUserAddResponse,
|
|
EmailUserRemoveResponse,
|
|
EmailUserSetPasswordResponse,
|
|
EmailAliasListResponse,
|
|
EmailAliasAddResponse,
|
|
EmailAliasRemoveResponse,
|
|
MonitorCheckListResponse,
|
|
MonitorCheckTypesResponse,
|
|
MonitorContactListResponse,
|
|
VmStartResponse,
|
|
VmStopResponse,
|
|
VmRebootResponse,
|
|
VmIpListResponse,
|
|
},
|
|
types::{
|
|
LunaNodeError,
|
|
LunaNodeRequest,
|
|
ApiKeys,
|
|
},
|
|
};
|
|
use lunanode_macros::lunanode_request;
|
|
use serde::{
|
|
Serialize,
|
|
Deserialize,
|
|
};
|
|
use serde_with::skip_serializing_none;
|
|
|
|
#[derive(Serialize, Deserialize, Debug, clap::Subcommand)]
|
|
/// All possible `ssh-key` subcommands.
|
|
pub enum SshKeySubArgs {
|
|
/// `ssh-key list`
|
|
List(SshKeyRequest),
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, clap::Subcommand)]
|
|
/// All possible `dyn` subcommands.
|
|
pub enum DynSubArgs {
|
|
/// `dyn list`
|
|
List(DynListRequest),
|
|
/// `dyn remove`
|
|
Remove(DynRemoveRequest),
|
|
/// `dyn add`
|
|
Add(DynAddRequest),
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, clap::Subcommand)]
|
|
/// All possible `zone` subcommands.
|
|
pub enum ZoneSubArgs {
|
|
/// `zone add`
|
|
Add(ZoneAddRequest),
|
|
/// `zone list`
|
|
List(ZoneListRequest),
|
|
/// `zone remove`
|
|
Remove(ZoneRemoveRequest),
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, clap::Subcommand)]
|
|
/// All possible `email domain` subcommands.
|
|
pub enum EmailDomainSubArgs {
|
|
/// `email domain list`
|
|
List(EmailDomainListRequest),
|
|
/// `email domain add`
|
|
Add(EmailDomainAddRequest),
|
|
/// `email domain remove`
|
|
Remove(EmailDomainRemoveRequest),
|
|
/// `email domain dkim-set`
|
|
DkimSet(EmailDomainDkimSetRequest),
|
|
/// `email domain dkim-unset`
|
|
DkimUnset(EmailDomainDkimUnsetRequest),
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, clap::Subcommand)]
|
|
/// All possible `email user` subcommands.
|
|
pub enum EmailUserSubArgs {
|
|
/// `email user list`
|
|
List(EmailUserListRequest),
|
|
/// `email user add`
|
|
Add(EmailUserAddRequest),
|
|
/// `email user remove`
|
|
Remove(EmailUserRemoveRequest),
|
|
/// `email user set-password`
|
|
SetPassword(EmailUserSetPasswordRequest),
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, clap::Subcommand)]
|
|
/// All possible `email alias` subcommands.
|
|
pub enum EmailAliasSubArgs {
|
|
/// `email alias list`
|
|
List(EmailAliasListRequest),
|
|
/// `email alias add`
|
|
Add(EmailAliasAddRequest),
|
|
/// `email alias remove`
|
|
Remove(EmailAliasRemoveRequest),
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, clap::Subcommand)]
|
|
/// All possible `email` subcommands.
|
|
pub enum EmailSubArgs {
|
|
#[clap(subcommand)]
|
|
/// `email domain`
|
|
Domain(EmailDomainSubArgs),
|
|
/// `email usage`
|
|
Usage(EmailUsageRequest),
|
|
#[clap(subcommand)]
|
|
/// `email user`
|
|
User(EmailUserSubArgs),
|
|
#[clap(subcommand)]
|
|
/// `email alias`
|
|
Alias(EmailAliasSubArgs)
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, clap::Subcommand)]
|
|
#[serde(untagged)]
|
|
/// All possible `floating` subcommands.
|
|
pub enum FloatingSubArgs {
|
|
/// List all images on my account.
|
|
List(FloatingIpListRequest),
|
|
}
|
|
#[derive(Serialize, Deserialize, Debug, clap::Subcommand)]
|
|
#[serde(untagged)]
|
|
/// All possible `image` subcommands.
|
|
pub enum ImageSubArgs {
|
|
/// List all images on my account.
|
|
List(ImageListRequest),
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, clap::Subcommand)]
|
|
#[serde(untagged)]
|
|
/// All possible `record` subcommands.
|
|
pub enum RecordSubArgs {
|
|
/// List all records in a domain.
|
|
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)]
|
|
#[serde(untagged)]
|
|
/// All `vm ip` subcommands.
|
|
pub enum VmIpSubArgs {
|
|
/// `vm ip list`
|
|
List(VmIpListRequest),
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, clap::Subcommand)]
|
|
#[serde(untagged)]
|
|
/// All `vm` subcommands.
|
|
pub enum VmSubArgs {
|
|
/// List all VMs on my account.
|
|
List(VmListRequest),
|
|
/// Restart a VM, given an ID.
|
|
Reboot(VmRebootRequest),
|
|
/// Stop a VM, given an ID.
|
|
Stop(VmStopRequest),
|
|
/// Turn on a VM, given an ID.
|
|
Start(VmStartRequest),
|
|
/// IP subcommands
|
|
#[clap(subcommand)]
|
|
Ip(VmIpSubArgs),
|
|
}
|
|
#[derive(Serialize, Deserialize, Debug, clap::Subcommand)]
|
|
#[serde(untagged)]
|
|
/// All `volume` subcommands.
|
|
pub enum VolumeSubArgs {
|
|
/// List all volumes I'm paying for.
|
|
List(VolumeListRequest),
|
|
}
|
|
#[derive(Serialize, Deserialize, Debug, clap::Subcommand)]
|
|
#[serde(untagged)]
|
|
/// All `billing` subcommands.
|
|
pub enum BillingSubArgs {
|
|
/// How much money is left in my account.
|
|
Credit(BillingCreditRequest),
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, clap::Subcommand)]
|
|
#[serde(untagged)]
|
|
/// All `network` subcommands.
|
|
pub enum NetworkSubArgs {
|
|
/// Networks on your accounts
|
|
List(NetworkListRequest),
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, clap::Subcommand)]
|
|
/// All `plan` subcommands.
|
|
pub enum PlanSubArgs {
|
|
/// `plan list`
|
|
List(PlanListRequest),
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, clap::Subcommand)]
|
|
/// All `region` subcommands.
|
|
pub enum RegionSubArgs {
|
|
/// `region list`
|
|
List(RegionListRequest),
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, clap::Subcommand)]
|
|
/// All `monitor check` subcommands.
|
|
pub enum MonitorCheckSubArgs {
|
|
/// `monitor check list`
|
|
List(MonitorCheckListRequest),
|
|
/// `monitor check types`
|
|
Types(MonitorCheckTypesRequest),
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, clap::Subcommand)]
|
|
/// All `monitor contact` subcommands.
|
|
pub enum MonitorContactSubArgs {
|
|
/// `monitor contact list`
|
|
List(MonitorContactListRequest),
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, clap::Subcommand)]
|
|
/// All `monitor` subcommands.
|
|
pub enum MonitorSubArgs {
|
|
#[clap(subcommand)]
|
|
/// All `monitor check` subcommands.
|
|
Check(MonitorCheckSubArgs),
|
|
#[clap(subcommand)]
|
|
/// All `monitor contact` subcommands.
|
|
Contact(MonitorContactSubArgs),
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, clap::Parser)]
|
|
#[serde(untagged)]
|
|
/// All possible commands that may be used at the command line.
|
|
pub enum Args {
|
|
#[clap(subcommand)]
|
|
/// See `lunanode image help`
|
|
Image(ImageSubArgs),
|
|
#[clap(subcommand)]
|
|
/// See `lunanode ip help`
|
|
Floating(FloatingSubArgs),
|
|
#[clap(subcommand)]
|
|
/// See `lunanode network help`
|
|
Network(NetworkSubArgs),
|
|
#[clap(subcommand)]
|
|
/// See `lunanode vm help`
|
|
Vm(VmSubArgs),
|
|
#[clap(subcommand)]
|
|
/// See `lunanode billing help`
|
|
Billing(BillingSubArgs),
|
|
#[clap(subcommand)]
|
|
/// See `lunanode volume help`
|
|
Volume(VolumeSubArgs),
|
|
#[clap(subcommand)]
|
|
/// See `lunanode zone help`
|
|
Zone(ZoneSubArgs),
|
|
#[clap(subcommand)]
|
|
/// See `lunanode record help`
|
|
Record(RecordSubArgs),
|
|
#[clap(subcommand)]
|
|
/// See `lunanode dyn help`
|
|
Dyn(DynSubArgs),
|
|
#[clap(subcommand)]
|
|
/// See `lunanode sshkey help`
|
|
SshKey(SshKeySubArgs),
|
|
#[clap(subcommand)]
|
|
/// See `lunandoe plan help`
|
|
Plan(PlanSubArgs),
|
|
#[clap(subcommand)]
|
|
/// See `lunanode region help`
|
|
Region(RegionSubArgs),
|
|
#[clap(subcommand)]
|
|
/// See `lunanode email help`
|
|
Email(EmailSubArgs),
|
|
#[clap(subcommand)]
|
|
/// See `lunanode monitor help`
|
|
Monitor(MonitorSubArgs),
|
|
}
|
|
|
|
/// Specifies an internal function which can only be called on LunaNodeRequests whoes response type implements Debug. This could be set in the structure itself, and probably should be.
|
|
fn print_req<T: LunaNodeRequest>(req: &T) -> Result<(), LunaNodeError>
|
|
where
|
|
<T as LunaNodeRequest>::Response: std::fmt::Debug
|
|
{
|
|
let ans = req.make_request()?;
|
|
println!("{:#?}", ans);
|
|
Ok(())
|
|
}
|
|
impl Args {
|
|
/// A generic make_request that unwraps the inner `impl LunaNodeRequest` type, and runs
|
|
/// make_request on those.
|
|
pub fn make_request(&self) -> Result<(), LunaNodeError> {
|
|
match self {
|
|
Self::Monitor(MonitorSubArgs::Contact(MonitorContactSubArgs::List(contact_list))) => print_req(contact_list)?,
|
|
Self::Monitor(MonitorSubArgs::Check(MonitorCheckSubArgs::Types(monitor_check_types))) => print_req(monitor_check_types)?,
|
|
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::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::Floating(FloatingSubArgs::List(ip_list)) => print_req(ip_list)?,
|
|
Self::Vm(VmSubArgs::List(vm_list)) => print_req(vm_list)?,
|
|
Self::Vm(VmSubArgs::Start(vm_to_start)) => print_req(vm_to_start)?,
|
|
Self::Vm(VmSubArgs::Stop(vm_to_stop)) => print_req(vm_to_stop)?,
|
|
Self::Vm(VmSubArgs::Ip(VmIpSubArgs::List(vm_ips))) => print_req(vm_ips)?,
|
|
Self::Vm(VmSubArgs::Reboot(vm_to_reboot)) => print_req(vm_to_reboot)?,
|
|
Self::Volume(VolumeSubArgs::List(vol_list)) => print_req(vol_list)?,
|
|
Self::Image(ImageSubArgs::List(image_list)) => print_req(image_list)?,
|
|
Self::Billing(BillingSubArgs::Credit(billing_credit)) => print_req(billing_credit)?,
|
|
Self::Zone(ZoneSubArgs::List(zone_list)) => print_req(zone_list)?,
|
|
Self::Zone(ZoneSubArgs::Add(zone_add_req)) => print_req(zone_add_req)?,
|
|
Self::Zone(ZoneSubArgs::Remove(zone_rem_req)) => print_req(zone_rem_req)?,
|
|
Self::Dyn(DynSubArgs::Add(dyn_add_req)) => print_req(dyn_add_req)?,
|
|
Self::Dyn(DynSubArgs::List(dyn_list)) => print_req(dyn_list)?,
|
|
Self::Dyn(DynSubArgs::Remove(dyn_del)) => print_req(dyn_del)?,
|
|
Self::Plan(PlanSubArgs::List(plan_list)) => print_req(plan_list)?,
|
|
Self::Region(RegionSubArgs::List(reg_list)) => print_req(reg_list)?,
|
|
Self::Email(EmailSubArgs::Usage(email_usage)) => print_req(email_usage)?,
|
|
Self::Email(EmailSubArgs::Domain(EmailDomainSubArgs::List(email_domain_list))) => print_req(email_domain_list)?,
|
|
Self::Email(EmailSubArgs::Domain(EmailDomainSubArgs::Add(email_domain_add_req))) => print_req(email_domain_add_req)?,
|
|
Self::Email(EmailSubArgs::Domain(EmailDomainSubArgs::Remove(email_domain_rem_req))) => print_req(email_domain_rem_req)?,
|
|
Self::Email(EmailSubArgs::Domain(EmailDomainSubArgs::DkimSet(email_domain_dkim_set))) => print_req(email_domain_dkim_set)?,
|
|
Self::Email(EmailSubArgs::Domain(EmailDomainSubArgs::DkimUnset(email_domain_dkim_unset))) => print_req(email_domain_dkim_unset)?,
|
|
Self::Email(EmailSubArgs::User(EmailUserSubArgs::List(email_user_list))) => print_req(email_user_list)?,
|
|
Self::Email(EmailSubArgs::User(EmailUserSubArgs::Add(email_add_user_req))) => print_req(email_add_user_req)?,
|
|
Self::Email(EmailSubArgs::User(EmailUserSubArgs::Remove(email_del_req))) => print_req(email_del_req)?,
|
|
Self::Email(EmailSubArgs::User(EmailUserSubArgs::SetPassword(email_user_set_password))) => print_req(email_user_set_password)?,
|
|
Self::Email(EmailSubArgs::Alias(EmailAliasSubArgs::List(email_alias_list))) => print_req(email_alias_list)?,
|
|
Self::Email(EmailSubArgs::Alias(EmailAliasSubArgs::Add(email_alias_add))) => print_req(email_alias_add)?,
|
|
Self::Email(EmailSubArgs::Alias(EmailAliasSubArgs::Remove(email_alias_rem))) => print_req(email_alias_rem)?,
|
|
}
|
|
Ok(())
|
|
}
|
|
}
|
|
|
|
/// ImageListRequest is used to create a new request for the /image/list endpoint.
|
|
#[lunanode_request(response="ImageListResponse", endpoint="image/list/")]
|
|
pub struct ImageListRequest {}
|
|
|
|
/// BillingCreditRequest handles the /billing/credits/ endpoint. It will produce a BillingCreditResponse.
|
|
#[lunanode_request(response="BillingCreditResponse", endpoint="billing/credit/")]
|
|
pub struct BillingCreditRequest {}
|
|
|
|
/// VMListRequest is used to create a new request for the /vm/list endpoint.
|
|
#[lunanode_request(response="VmListResponse", endpoint="vm/list/")]
|
|
pub struct VmListRequest {}
|
|
|
|
/// VolumeListRequest is used to create a new request for the /volume/list endpoint.
|
|
#[lunanode_request(response="VolumeListResponse", endpoint="volume/list/")]
|
|
pub struct VolumeListRequest {}
|
|
|
|
/// IpListRequest is used to create a new request for the /ip/list endpoint.
|
|
#[lunanode_request(response="FloatingIpListResponse", endpoint="floating/list/")]
|
|
pub struct FloatingIpListRequest {}
|
|
|
|
/// NetworkListRequest is used to create a new request for the /network/list endpoint.
|
|
#[lunanode_request(response="NetworkListResponse", endpoint="network/list/")]
|
|
pub struct NetworkListRequest {}
|
|
|
|
/// ZoneListRequest is used to generate a request for the dns2/zone-list/ endpoint.
|
|
#[lunanode_request(response="ZoneListResponse", endpoint="dns2/zone-list/")]
|
|
pub struct ZoneListRequest {}
|
|
|
|
/// RecordListRequest is used to get information about a specific DNS zone (usually an entire domain, but could also be a subdomain).
|
|
#[lunanode_request(response="RecordListResponse", endpoint="dns2/record-list/")]
|
|
pub struct RecordListRequest {
|
|
zone_id: i32
|
|
}
|
|
|
|
/// DynListRequest is used to get information about the dynamic DNS records set for all lunanode zones.
|
|
#[lunanode_request(response="DynListResponse", endpoint="dns/dyn-list/")]
|
|
pub struct DynListRequest {}
|
|
|
|
#[lunanode_request(response="SshKeyResponse", endpoint="sshkey/list/")]
|
|
/// A request to show all SSH public keys stored on the user's Lunanode account.
|
|
pub struct SshKeyRequest {}
|
|
|
|
#[lunanode_request(response="PlanListResponse", endpoint="plan/list/")]
|
|
/// A request to list all possible plans the user may create a new VM with.
|
|
pub struct PlanListRequest {}
|
|
|
|
#[lunanode_request(response="RegionListResponse", endpoint="region/list/")]
|
|
/// A request so show all regions available for the user to choose from.
|
|
pub struct RegionListRequest {}
|
|
|
|
#[lunanode_request(response="EmailUsageResponse", endpoint="email/usage/")]
|
|
/// A request to show an email usage report.
|
|
pub struct EmailUsageRequest {}
|
|
|
|
#[lunanode_request(response="EmailDomainListResponse", endpoint="email/domain-list/")]
|
|
/// A request to show all email domains managed by the user's Lunanode account.
|
|
pub struct EmailDomainListRequest {}
|
|
|
|
#[lunanode_request(response="MonitorCheckListResponse", endpoint="monitor/check-list/")]
|
|
/// A request to show all monitor checks (active and inactive).
|
|
pub struct MonitorCheckListRequest {}
|
|
|
|
#[lunanode_request(response="MonitorCheckTypesResponse", endpoint="monitor/check-types/")]
|
|
/// A request to check all possible monitor check types.
|
|
pub struct MonitorCheckTypesRequest {}
|
|
|
|
/// A request to show all contacts on the monitor list.
|
|
#[lunanode_request(response="MonitorContactListResponse", endpoint="monitor/contact-list/")]
|
|
pub struct MonitorContactListRequest {}
|
|
|
|
#[lunanode_request(response="EmailUserListResponse", endpoint="email/user-list/")]
|
|
/// A request to show all email users in a domain.
|
|
pub struct EmailUserListRequest {
|
|
/// The domain ID to list users in.
|
|
domain_id: i32,
|
|
}
|
|
|
|
#[lunanode_request(response="VmStartResponse", endpoint="vm/start/")]
|
|
/// A request to start a VM.
|
|
pub struct VmStartRequest {
|
|
/// The ID of the VM to start. See [`VmListRequest`]
|
|
vm_id: String,
|
|
}
|
|
|
|
#[lunanode_request(response="VmStopResponse", endpoint="vm/stop/")]
|
|
/// A request to stop a VM.
|
|
pub struct VmStopRequest {
|
|
/// The ID of the VM to stop. See [`VmListRequest`]
|
|
vm_id: String,
|
|
}
|
|
|
|
#[lunanode_request(response="VmRebootResponse", endpoint="vm/reboot/")]
|
|
/// A request to reboot a VM.
|
|
pub struct VmRebootRequest {
|
|
/// The ID of the VM to reboot. See [`VmListRequest`]
|
|
vm_id: String,
|
|
}
|
|
|
|
#[lunanode_request(response="EmailUserAddResponse", endpoint="email/user-add/")]
|
|
/// A request to add a new email account to a domain.
|
|
pub struct EmailUserAddRequest {
|
|
/// The domain ID to add the user to. See [`EmailDomainListRequest`]
|
|
domain_id: i32,
|
|
/// The username of the new user.
|
|
username: String,
|
|
/// The password of the new user.
|
|
password: String,
|
|
}
|
|
|
|
#[lunanode_request(response="EmailUserRemoveResponse", endpoint="email/user-remove/")]
|
|
/// A request to remove a user from a domain's email.
|
|
pub struct EmailUserRemoveRequest {
|
|
/// An ID of the domain to remove the user from.
|
|
domain_id: i32,
|
|
/// The ID of the user to remove. See [`EmailUserListRequest`]
|
|
user_id: i32,
|
|
}
|
|
|
|
#[lunanode_request(response="EmailUserSetPasswordResponse", endpoint="email/user-set-password/")]
|
|
/// A request to set an email user's password on a specific domain.
|
|
pub struct EmailUserSetPasswordRequest {
|
|
/// The ID of the domain the user is on.
|
|
domain_id: i32,
|
|
/// The user ID of the user on the domain.
|
|
user_id: i32,
|
|
/// The new password.
|
|
password: String,
|
|
}
|
|
|
|
#[lunanode_request(response="VmIpListResponse", endpoint="vm/iplist/")]
|
|
/// A request to list all IPs associated with a VM.
|
|
pub struct VmIpListRequest {
|
|
/// The VM whoes IPs to list.
|
|
vm_id: String,
|
|
}
|
|
|
|
#[lunanode_request(response="DynRemoveResponse", endpoint="dns/dyn-remove/")]
|
|
/// A request to remove a dyn record.
|
|
pub struct DynRemoveRequest {
|
|
/// The ID of the dyn record to remove. See [`DynListrRequest`]
|
|
dyn_id: i32,
|
|
}
|
|
|
|
#[lunanode_request(response="DynAddResponse", endpoint="dns/dyn-add/")]
|
|
/// A request to add a new dyn record.
|
|
pub struct DynAddRequest {
|
|
/// The data string for the record. This is usually a FQDN, followed by a period. If you wanted to set a record for `dev.example.org`, you would put `dev.example.com.` in this field.
|
|
name: String,
|
|
/// An ip address to associate with the FQDN. This type should be stricter: TODO.
|
|
ip: String,
|
|
}
|
|
|
|
#[lunanode_request(response="ZoneAddResponse", endpoint="dns2/zone-add/")]
|
|
/// A request to add a new zone.
|
|
pub struct ZoneAddRequest {
|
|
/// A new zone, a FQDN.
|
|
name: String,
|
|
/// The default time-to-live (TTL) for the records in this zone.
|
|
ttl: i32,
|
|
}
|
|
|
|
#[lunanode_request(response="ZoneRemoveResponse", endpoint="dns2/zone-remove/")]
|
|
/// A request to remove a zone entirely from Luanode's control.
|
|
/// Be very careful doing this, as this will likely remove ***ALL*** of your records associated
|
|
/// with the domain.
|
|
pub struct ZoneRemoveRequest {
|
|
/// The zone to remove. See also: [`ZoneListRequest`]
|
|
zone_id: i32,
|
|
}
|
|
|
|
#[derive(Serialize, Deserialize, Debug, Clone, Eq, Hash, PartialEq, clap::ValueEnum)]
|
|
#[serde(rename_all="lowercase")]
|
|
/// A record policy type related to how to restrict usage of the record. For example: Latlong (for location-based) and Region (for country based).
|
|
pub enum RecordPolicyType {
|
|
/// No restriction.
|
|
r#None,
|
|
/// Latitude & Longitude restirction.
|
|
LatLong,
|
|
/// Political region restriction.
|
|
Region,
|
|
}
|
|
|
|
#[skip_serializing_none]
|
|
#[lunanode_request(response="RecordAddResponse", endpoint="dns2/record-add/")]
|
|
/// Add a new DNS record to your zone.
|
|
pub struct RecordAddRequest {
|
|
/// Reference the zone (see: [`requests::ZoneListResponse`])
|
|
zone_id: i32,
|
|
/// The name field for the record. @ sign is used for a root zone.
|
|
name: String,
|
|
/// The data field for the record. This is usually an IP address, but TXT records may contain any text.
|
|
data: String,
|
|
/// Time-To-Live: the defines how often this record should be re-cached.
|
|
ttl: i32,
|
|
r#type: RecordType,
|
|
/// The priority for certain record types, like MX and SRV.
|
|
aux: Option<i32>,
|
|
policy: Option<RecordPolicyType>,
|
|
/// The record weight (this is used for balancing or non-round-robin DNS failover).
|
|
weight: Option<i32>,
|
|
/// latitude if policy is `latlong`
|
|
latitude: Option<String>,
|
|
/// longitude if policy is `latlong`
|
|
longitude: Option<String>,
|
|
/// The ID of a monitor check (see `monitor check list`), this record will be disabled if the check fails.
|
|
monitor_id: Option<String>,
|
|
/// If set, update the existing record with this ID instead of creating a new record.
|
|
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,
|
|
}
|
|
|
|
#[lunanode_request(response="EmailDomainAddResponse", endpoint="email/domain-add/")]
|
|
/// Adds a new domain to Lunanode's email server.
|
|
pub struct EmailDomainAddRequest {
|
|
/// The domain name you would like to add mail service for.
|
|
name: String,
|
|
}
|
|
|
|
#[lunanode_request(response="EmailDomainRemoveResponse", endpoint="email/domain-remove/")]
|
|
/// Removes a domain from Lunanode's email service.
|
|
pub struct EmailDomainRemoveRequest {
|
|
/// The domain id which should be removed. See: [`EmailDomainListRequest`]
|
|
domain_id: i32,
|
|
}
|
|
|
|
#[lunanode_request(response="EmailAliasListResponse", endpoint="email/alias-list/")]
|
|
/// Show all aliases for a given domain's email.
|
|
pub struct EmailAliasListRequest {
|
|
/// The domain id for which the email alias records will be fetched. See: [`EmailDomainListRequest`]
|
|
domain_id: i32,
|
|
}
|
|
|
|
#[lunanode_request(response="EmailAliasAddResponse", endpoint="email/alias-add/")]
|
|
/// Add an email alias or a catch-all address.
|
|
pub struct EmailAliasAddRequest {
|
|
/// The domain id for which the alias will be set on. See: [`EmailDomainListRequest`]
|
|
domain_id: i32,
|
|
/// The name of the alias XYZ@example.com (use a blank string here for a catch-all).
|
|
name: String,
|
|
/// The destination of the alias, which should be an existing address on the system.
|
|
target: String,
|
|
}
|
|
|
|
#[lunanode_request(response="EmailAliasRemoveResponse", endpoint="email/alias-remove/")]
|
|
/// Remove an email alias.
|
|
pub struct EmailAliasRemoveRequest {
|
|
/// The domain id for which the email alias will be deletes.
|
|
domain_id: i32,
|
|
/// The alias id to delete.
|
|
alias_id: i32,
|
|
}
|
|
|
|
#[lunanode_request(response="EmailDomainDkimSetResponse", endpoint="email/domain-dkim-set/")]
|
|
/// Set a DKIM private key and selector for an email domain.
|
|
pub struct EmailDomainDkimSetRequest {
|
|
/// The domain id for which the dkim key will be set.
|
|
domain_id: i32,
|
|
/// DKIM selector.
|
|
selector: String,
|
|
/// Private key contents
|
|
private_key: String,
|
|
}
|
|
|
|
#[lunanode_request(response="EmailDomainDkimUnsetResponse", endpoint="email/domain-dkim-unset/")]
|
|
/// Remove a DKIM key.
|
|
pub struct EmailDomainDkimUnsetRequest {
|
|
/// The domain id for which the dkim key will be unset.
|
|
domain_id: i32,
|
|
}
|