cloud_dns/api/
managed_zone_operations.rs

1use crate::{DnsClient, Result};
2
3use super::managed_zones::ManagedZone;
4use super::{dns_keys::DnsKey, ListEnvelope};
5use serde::{Deserialize, Serialize};
6
7#[derive(Serialize, Deserialize, Debug)]
8#[serde(rename_all = "camelCase")]
9pub struct ManagedZoneOperation {
10    pub kind: String, // "dns#operation"
11    pub id: String,
12    pub start_time: String,
13    pub status: String,
14    pub user: String,
15    pub r#type: String,
16    pub zone_context: ZoneContext,
17    pub dns_key_context: DnsKeyContext,
18}
19
20#[derive(Serialize, Deserialize, Debug)]
21#[serde(rename_all = "camelCase")]
22pub struct ZoneContext {
23    pub old_value: ManagedZone,
24    pub new_value: ManagedZone,
25}
26
27#[derive(Serialize, Deserialize, Debug)]
28#[serde(rename_all = "camelCase")]
29pub struct DnsKeyContext {
30    pub old_value: DnsKey,
31    pub new_value: DnsKey,
32}
33
34#[derive(Serialize, Deserialize, Debug)]
35#[serde(rename_all = "camelCase")]
36pub struct ManagedZoneOperations {
37    #[serde(flatten)]
38    pub envelope: ListEnvelope,
39    pub operations: Vec<ManagedZoneOperation>,
40}
41
42pub struct ManagedZoneOperationsHandler<'client> {
43    client: &'client DnsClient,
44}
45
46impl<'client> ManagedZoneOperationsHandler<'client> {
47    pub(crate) fn new(client: &'client DnsClient) -> Self {
48        Self { client }
49    }
50
51    pub async fn list(&self, managed_zone: &str) -> Result<ManagedZoneOperations> {
52        let route = format!(
53            "managedZones/{managed_zone}/operations",
54            managed_zone = managed_zone,
55        );
56
57        self.client.get(route).await
58    }
59
60    pub async fn get(
61        &self,
62        managed_zone: &str,
63        operation_id: &str,
64    ) -> Result<ManagedZoneOperation> {
65        let route = format!(
66            "managedZones/{managed_zone}/operations/{operation_id}",
67            managed_zone = managed_zone,
68            operation_id = operation_id,
69        );
70
71        self.client.get(route).await
72    }
73}