(&self, record: &impl Serialize)
| 164 | } |
| 165 | |
| 166 | async fn add_record(&self, record: &impl Serialize) -> Result<Response> { |
| 167 | let client = Client::new(); |
| 168 | let url = format!("{}/zones/{}/dns_records", self.api_url, self.zone_id); |
| 169 | let response = client |
| 170 | .post(&url) |
| 171 | .header("Authorization", format!("Bearer {}", self.api_token)) |
| 172 | .header("Content-Type", "application/json") |
| 173 | .json(record) |
| 174 | .send() |
| 175 | .await |
| 176 | .context("failed to send add_record request")?; |
| 177 | |
| 178 | let status = response.status(); |
| 179 | let body = response |
| 180 | .text() |
| 181 | .await |
| 182 | .context("failed to read add_record response body")?; |
| 183 | if !status.is_success() { |
| 184 | anyhow::bail!("failed to add record: {body}"); |
| 185 | } |
| 186 | let response = serde_json::from_str(&body).context("failed to parse response")?; |
| 187 | Ok(response) |
| 188 | } |
| 189 | |
| 190 | async fn remove_record_inner(&self, record_id: &str) -> Result<()> { |
| 191 | let client = Client::new(); |
no test coverage detected