devops_armory/cloud/gcp/dns/
get.rs1use std::time::Duration;
2
3pub async fn get_records_set(
5 token: String,
6 project: String,
7 managed_zone: String,
8 dns_name: String,
9 dns_type: String
10) -> Result<(), std::io::Error> {
11
12 let client = awc::Client::default();
13 let request = client.get(format!("https://dns.googleapis.com/dns/v1/projects/{project}/managedZones/{managed_zone}/rrsets/{dns_name}/{dns_type}"))
14 .bearer_auth(&token)
15 .insert_header(("Content-Type", "application/json"))
16 .timeout(Duration::from_secs(30))
17 .send()
18 .await
19 .unwrap();
20
21 let mut req = request;
22 let req_status = req.status().as_u16();
23 let respone = req.body().await.unwrap_or_default();
24
25 match req_status {
26
27 200 => {
28 println!("Request has been successfull: Status: {:?}, {:?}", req_status, respone);
29 },
30 400 => {
31 println!("Bad Request. Check URL parameters or body: {:?}", respone);
32 },
33 403 => {
34 println!("You don't have access to perform such request: {:?}", respone);
35 }
36 404 => {
37 println!("Requested resource does not exists: {:?}", respone);
38 },
39 409 => {
40 println!("Requested resource already exists! {:?}", respone)
41 }
42 _ => {
43 println!("Request status mismatch. Check response: {:?}", respone);
44 }
45
46 }
47
48 Ok(())
49
50}
51