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