Skip to main content

box_open_sdk/managers/
file_classifications.rs

1// Code generated by box-gantry. DO NOT EDIT.
2
3use crate::internal::path_escape;
4use crate::runtime::{self, Error};
5
6/// Operations for the "file_classifications" API area.
7pub struct FileClassificationsManager {
8    session: std::sync::Arc<runtime::Client>,
9}
10
11impl FileClassificationsManager {
12    pub(crate) fn new(session: std::sync::Arc<runtime::Client>) -> Self {
13        Self { session }
14    }
15
16    pub async fn get(
17        &self,
18        file_id: String,
19    ) -> Result<crate::models::schemas::Classification, Error> {
20        let mut url = self.session.base_url("api");
21        url.push_str("/files");
22        url.push('/');
23        let seg = path_escape(&file_id);
24        url.push_str(&seg);
25        url.push_str("/metadata");
26        url.push_str("/enterprise");
27        url.push_str("/securityClassification-6VMVochwUWo");
28        let req = self.session.new_request("GET", &url);
29        let resp = self.session.fetch(req).await?;
30        let data = runtime::response_bytes(&resp)?;
31        Ok(serde_json::from_slice(&data)?)
32    }
33
34    pub async fn update(
35        &self,
36        file_id: String,
37        body: Vec<crate::models::schemas::FileClassificationUpdateRequest>,
38    ) -> Result<crate::models::schemas::Classification, Error> {
39        let mut url = self.session.base_url("api");
40        url.push_str("/files");
41        url.push('/');
42        let seg = path_escape(&file_id);
43        url.push_str(&seg);
44        url.push_str("/metadata");
45        url.push_str("/enterprise");
46        url.push_str("/securityClassification-6VMVochwUWo");
47        let mut req = self.session.new_request("PUT", &url);
48        let payload = serde_json::to_vec(&body)?;
49        req = runtime::with_json_body(req, &payload);
50        let resp = self.session.fetch(req).await?;
51        let data = runtime::response_bytes(&resp)?;
52        Ok(serde_json::from_slice(&data)?)
53    }
54
55    pub async fn create(
56        &self,
57        file_id: String,
58        body: crate::models::schemas::FileClassificationCreateRequest,
59    ) -> Result<crate::models::schemas::Classification, Error> {
60        let mut url = self.session.base_url("api");
61        url.push_str("/files");
62        url.push('/');
63        let seg = path_escape(&file_id);
64        url.push_str(&seg);
65        url.push_str("/metadata");
66        url.push_str("/enterprise");
67        url.push_str("/securityClassification-6VMVochwUWo");
68        let mut req = self.session.new_request("POST", &url);
69        let payload = serde_json::to_vec(&body)?;
70        req = runtime::with_json_body(req, &payload);
71        let resp = self.session.fetch(req).await?;
72        let data = runtime::response_bytes(&resp)?;
73        Ok(serde_json::from_slice(&data)?)
74    }
75
76    pub async fn delete(&self, file_id: String) -> Result<(), Error> {
77        let mut url = self.session.base_url("api");
78        url.push_str("/files");
79        url.push('/');
80        let seg = path_escape(&file_id);
81        url.push_str(&seg);
82        url.push_str("/metadata");
83        url.push_str("/enterprise");
84        url.push_str("/securityClassification-6VMVochwUWo");
85        let req = self.session.new_request("DELETE", &url);
86        let _ = self.session.fetch(req).await?;
87        Ok(())
88    }
89}