gsuite_api/
domains.rs

1use crate::Client;
2use crate::ClientResult;
3
4pub struct Domains {
5    pub client: Client,
6}
7
8impl Domains {
9    #[doc(hidden)]
10    pub fn new(client: Client) -> Self {
11        Domains { client }
12    }
13
14    /**
15     * This function performs a `GET` to the `/admin/directory/v1/customer/{customer}/domains` endpoint.
16     *
17     * Lists the domains of the customer.
18     *
19     * **Parameters:**
20     *
21     * * `customer: &str` -- Immutable ID of the Google Workspace account.
22     */
23    pub async fn list(
24        &self,
25        customer: &str,
26    ) -> ClientResult<crate::Response<crate::types::Domains2>> {
27        let url = self.client.url(
28            &format!(
29                "/admin/directory/v1/customer/{}/domains",
30                crate::progenitor_support::encode_path(customer),
31            ),
32            None,
33        );
34        self.client
35            .get(
36                &url,
37                crate::Message {
38                    body: None,
39                    content_type: None,
40                },
41            )
42            .await
43    }
44    /**
45     * This function performs a `POST` to the `/admin/directory/v1/customer/{customer}/domains` endpoint.
46     *
47     * Inserts a domain of the customer.
48     *
49     * **Parameters:**
50     *
51     * * `customer: &str` -- Immutable ID of the Google Workspace account.
52     */
53    pub async fn insert(
54        &self,
55        customer: &str,
56        body: &crate::types::Domains,
57    ) -> ClientResult<crate::Response<crate::types::Domains>> {
58        let url = self.client.url(
59            &format!(
60                "/admin/directory/v1/customer/{}/domains",
61                crate::progenitor_support::encode_path(customer),
62            ),
63            None,
64        );
65        self.client
66            .post(
67                &url,
68                crate::Message {
69                    body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
70                    content_type: Some("application/json".to_string()),
71                },
72            )
73            .await
74    }
75    /**
76     * This function performs a `GET` to the `/admin/directory/v1/customer/{customer}/domains/{domainName}` endpoint.
77     *
78     * Retrieves a domain of the customer.
79     *
80     * **Parameters:**
81     *
82     * * `customer: &str` -- Immutable ID of the Google Workspace account.
83     * * `domain_name: &str` -- Name of domain to be retrieved.
84     */
85    pub async fn get(
86        &self,
87        customer: &str,
88        domain_name: &str,
89    ) -> ClientResult<crate::Response<crate::types::Domains>> {
90        let url = self.client.url(
91            &format!(
92                "/admin/directory/v1/customer/{}/domains/{}",
93                crate::progenitor_support::encode_path(customer),
94                crate::progenitor_support::encode_path(domain_name),
95            ),
96            None,
97        );
98        self.client
99            .get(
100                &url,
101                crate::Message {
102                    body: None,
103                    content_type: None,
104                },
105            )
106            .await
107    }
108    /**
109     * This function performs a `DELETE` to the `/admin/directory/v1/customer/{customer}/domains/{domainName}` endpoint.
110     *
111     * Deletes a domain of the customer.
112     *
113     * **Parameters:**
114     *
115     * * `customer: &str` -- Immutable ID of the Google Workspace account.
116     * * `domain_name: &str` -- Name of domain to be deleted.
117     */
118    pub async fn delete(
119        &self,
120        customer: &str,
121        domain_name: &str,
122    ) -> ClientResult<crate::Response<()>> {
123        let url = self.client.url(
124            &format!(
125                "/admin/directory/v1/customer/{}/domains/{}",
126                crate::progenitor_support::encode_path(customer),
127                crate::progenitor_support::encode_path(domain_name),
128            ),
129            None,
130        );
131        self.client
132            .delete(
133                &url,
134                crate::Message {
135                    body: None,
136                    content_type: None,
137                },
138            )
139            .await
140    }
141}