oxide_api/
policy.rs

1use anyhow::Result;
2
3use crate::Client;
4
5pub struct Policy {
6    pub client: Client,
7}
8
9impl Policy {
10    #[doc(hidden)]
11    pub fn new(client: Client) -> Self {
12        Policy { client }
13    }
14
15    /**
16     * Fetch the top-level IAM policy.
17     *
18     * This function performs a `GET` to the `/global/policy` endpoint.
19     */
20    pub async fn global_view(&self) -> Result<crate::types::FleetRolePolicy> {
21        let url = "/global/policy".to_string();
22        self.client.get(&url, None).await
23    }
24
25    /**
26     * Update the top-level IAM policy.
27     *
28     * This function performs a `PUT` to the `/global/policy` endpoint.
29     */
30    pub async fn global_update(
31        &self,
32        body: &crate::types::FleetRolePolicy,
33    ) -> Result<crate::types::FleetRolePolicy> {
34        let url = "/global/policy".to_string();
35        self.client
36            .put(&url, Some(reqwest::Body::from(serde_json::to_vec(body)?)))
37            .await
38    }
39}