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