cloud_storage/sync/
object_access_control.rs

1use crate::{
2    bucket_access_control::Entity,
3    object_access_control::{NewObjectAccessControl, ObjectAccessControl},
4};
5
6/// Operations on [`ObjectAccessControl`](ObjectAccessControl)s.
7#[derive(Debug)]
8pub struct ObjectAccessControlClient<'a>(pub(super) &'a super::Client);
9
10impl<'a> ObjectAccessControlClient<'a> {
11    /// Creates a new ACL entry on the specified `object`.
12    ///
13    /// ### Important
14    /// This method fails with a 400 Bad Request response for buckets with uniform
15    /// bucket-level access enabled. Use `Bucket::get_iam_policy` and `Bucket::set_iam_policy` to
16    /// control access instead.
17    pub fn create(
18        &self,
19        bucket: &str,
20        object: &str,
21        new_object_access_control: &NewObjectAccessControl,
22    ) -> crate::Result<ObjectAccessControl> {
23        self.0
24            .runtime
25            .block_on(self.0.client.object_access_control().create(
26                bucket,
27                object,
28                new_object_access_control,
29            ))
30    }
31
32    /// Retrieves `ACL` entries on the specified object.
33    ///
34    /// ### Important
35    /// Important: This method fails with a 400 Bad Request response for buckets with uniform
36    /// bucket-level access enabled. Use `Bucket::get_iam_policy` and `Bucket::set_iam_policy` to
37    /// control access instead.
38    pub fn list(&self, bucket: &str, object: &str) -> crate::Result<Vec<ObjectAccessControl>> {
39        self.0
40            .runtime
41            .block_on(self.0.client.object_access_control().list(bucket, object))
42    }
43
44    /// Returns the `ACL` entry for the specified entity on the specified bucket.
45    ///
46    /// ### Important
47    /// Important: This method fails with a 400 Bad Request response for buckets with uniform
48    /// bucket-level access enabled. Use `Bucket::get_iam_policy` and `Bucket::set_iam_policy` to
49    /// control access instead.
50    pub fn read(
51        &self,
52        bucket: &str,
53        object: &str,
54        entity: &Entity,
55    ) -> crate::Result<ObjectAccessControl> {
56        self.0.runtime.block_on(
57            self.0
58                .client
59                .object_access_control()
60                .read(bucket, object, entity),
61        )
62    }
63
64    /// Updates an ACL entry on the specified object.
65    ///
66    /// ### Important
67    /// Important: This method fails with a 400 Bad Request response for buckets with uniform
68    /// bucket-level access enabled. Use `Bucket::get_iam_policy` and `Bucket::set_iam_policy` to
69    /// control access instead.
70    pub fn update(
71        &self,
72        object_access_control: &ObjectAccessControl,
73    ) -> crate::Result<ObjectAccessControl> {
74        self.0.runtime.block_on(
75            self.0
76                .client
77                .object_access_control()
78                .update(object_access_control),
79        )
80    }
81
82    /// Permanently deletes the ACL entry for the specified entity on the specified object.
83    ///
84    /// ### Important
85    /// Important: This method fails with a 400 Bad Request response for buckets with uniform
86    /// bucket-level access enabled. Use `Bucket::get_iam_policy` and `Bucket::set_iam_policy` to
87    /// control access instead.
88    pub fn delete(&self, object_access_control: ObjectAccessControl) -> crate::Result<()> {
89        self.0.runtime.block_on(
90            self.0
91                .client
92                .object_access_control()
93                .delete(object_access_control),
94        )
95    }
96}