diff --git a/src/requests.rs b/src/requests.rs index d7b7ad7..5e119b0 100644 --- a/src/requests.rs +++ b/src/requests.rs @@ -10,6 +10,10 @@ use crate::{ RecordListResponse, DynListResponse, SshKeyResponse, + PlanListResponse, + RegionListResponse, + EmailUsageResponse, + EmailDomainListResponse, }, types::{ LNError, @@ -43,6 +47,18 @@ pub enum ZoneSubArgs { List(ZoneListRequest), } +#[derive(Serialize, Deserialize, Debug, clap::Subcommand)] +pub enum EmailDomainSubArgs { + List(EmailDomainListRequest), +} + +#[derive(Serialize, Deserialize, Debug, clap::Subcommand)] +pub enum EmailSubArgs { + #[clap(subcommand)] + Domain(EmailDomainSubArgs), + Usage(EmailUsageRequest), +} + #[derive(Serialize, Deserialize, Debug, clap::Subcommand)] #[serde(untagged)] pub enum FloatingSubArgs { @@ -88,6 +104,16 @@ pub enum NetworkSubArgs { List(NetworkListRequest), } +#[derive(Serialize, Deserialize, Debug, clap::Subcommand)] +pub enum PlanSubArgs { + List(PlanListRequest), +} + +#[derive(Serialize, Deserialize, Debug, clap::Subcommand)] +pub enum RegionSubArgs { + List(RegionListRequest), +} + #[derive(Serialize, Deserialize, Debug, clap::Parser)] #[serde(untagged)] pub enum Args { @@ -121,6 +147,15 @@ pub enum Args { #[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), } /// 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. @@ -145,6 +180,10 @@ impl Args { Self::Billing(BillingSubArgs::Credit(billing_credit)) => print_req(billing_credit)?, Self::Zone(ZoneSubArgs::List(zone_list)) => print_req(zone_list)?, Self::Dyn(DynSubArgs::List(dyn_list)) => print_req(dyn_list)?, + 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)?, } Ok(()) } @@ -190,3 +229,15 @@ pub struct DynListRequest {} #[lunanode_request(response="SshKeyResponse", endpoint="sshkey/list/")] pub struct SshKeyRequest {} + +#[lunanode_request(response="PlanListResponse", endpoint="plan/list/")] +pub struct PlanListRequest {} + +#[lunanode_request(response="RegionListResponse", endpoint="region/list/")] +pub struct RegionListRequest {} + +#[lunanode_request(response="EmailUsageResponse", endpoint="email/usage/")] +pub struct EmailUsageRequest {} + +#[lunanode_request(response="EmailDomainListResponse", endpoint="email/domain-list/")] +pub struct EmailDomainListRequest {} diff --git a/src/responses.rs b/src/responses.rs index d2376bd..5355164 100644 --- a/src/responses.rs +++ b/src/responses.rs @@ -475,9 +475,42 @@ pub struct SshKey { value: String, } +#[lunanode_response] +pub struct RegionListResponse { + regions: std::collections::HashMap, +} + #[lunanode_response] pub struct SshKeyResponse { #[serde(flatten)] /// List of keys stored in the LunaNode cloud. The String is just an index that I can't get to flatten :grumpy programmer noises: keys: std::collections::HashMap, } + +#[lunanode_response] +pub struct EmailUsageResponse { + #[serde_as(as="DisplayFromStr")] + domains: i32, + /// Usage of email in GB, this should be an i32. + storage: String, + /// Usage of email in GB with GB appended to the end of the string, + storage_nice: String, + #[serde_as(as="DisplayFromStr")] + messages: i32, +} + +#[serde_as] +#[derive(Serialize, Deserialize, Debug)] +pub struct EmailDomainInfo { + #[serde_as(as="DisplayFromStr")] + id: i32, + name: String, + storage: String, + storage_nice: String, +} + +#[lunanode_response] +pub struct EmailDomainListResponse { + #[serde(flatten)] + domains: std::collections::HashMap, +}