use jdcloud_signer::{Credential, Signer, Client}; use http::Request; use serde_json::Value; fn main() { let ak = "..."; let sk = "..."; let credential = Credential::new(ak, sk); let signer = Signer::new(credential, "vm".to_string(), "cn-north-1".to_string()); let mut req = Request::builder(); let mut req = req.method("GET") .uri("http://vm.jdcloud-api.com/v1/regions/cn-north-1/instances") .body("".to_string()).unwrap(); signer.sign_request(&mut req).unwrap(); let client = Client::new(); let mut res = client.execute(req).unwrap(); println!("status: {}", res.status()); for header in res.headers().into_iter() { println!("{}: {:?}", header.0, header.1); } let text = res.text().unwrap(); let json: Value = serde_json::from_str(&text).unwrap(); println!("requestId: {}", json["requestId"]); }