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.

72 lines
1.5 KiB

pub mod success;
pub mod external;
pub mod requests;
pub mod responses;
pub mod types;
use ureq::{
json,
post
};
use sha2::Sha512;
use hmac::{Hmac, Mac};
use responses::{
VMListResponse,
PlanListResponse,
LNImageListResponse,
BillingCreditResponse,
VMInfoResponse,
};
use serde::{
de::DeserializeOwned,
Serialize,
Deserialize,
};
use requests::{
Args,
VMListRequest,
};
use types::{
ApiKeys,
};
use clap::Parser;
/*
Define types for all different types of API requests.
Every valid enum value is the type of API request, and within it, a structure representing that API call.
No inner struct is required for requests that do not take arguments.
*/
#[derive(Serialize, Deserialize, Eq, PartialEq, Hash, Debug)]
enum LunaNodeAPIRequest {
BillingCredit,
ImageList,
PlanList,
RegionList,
VmInfo,
VmList(VMListRequest),
}
impl LunaNodeAPIRequest {
fn url_endpoint(&self) -> &str {
match self {
Self::BillingCredit => "billing/credit/",
Self::ImageList => "image/list/",
Self::PlanList => "plan/list/",
Self::RegionList => "region/list/",
Self::VmInfo => "vm/info/",
Self::VmList(_) => "vm/list/",
}
}
}
impl ToString for LunaNodeAPIRequest {
// TODO: don't do this; this should actually serialzie the object somehow
fn to_string(&self) -> String {
self.url_endpoint().to_string()
}
}
fn main() -> Result<(), Box<dyn std::error::Error>> {
let args = Args::parse();
let _ = args.make_request();
Ok(())
}