Struct cloud_storage::sync::BucketClient [−][src]
pub struct BucketClient<'a>(_);
Expand description
Operations on Buckets.
Implementations
impl<'a> BucketClient<'a>[src]
impl<'a> BucketClient<'a>[src]pub fn create(&self, new_bucket: &NewBucket) -> Result<Bucket>[src]
pub fn create(&self, new_bucket: &NewBucket) -> Result<Bucket>[src]Creates a new Bucket. There are many options that you can provide for creating a new
bucket, so the NewBucket resource contains all of them. Note that NewBucket implements
Default, so you don’t have to specify the fields you’re not using. And error is returned
if that bucket name is already taken.
Example
use cloud_storage::sync::Client; use cloud_storage::bucket::{Bucket, NewBucket}; use cloud_storage::bucket::{Location, MultiRegion}; let client = Client::new()?; let new_bucket = NewBucket { name: "cloud-storage-rs-doc-1".to_string(), // this is the only mandatory field location: Location::Multi(MultiRegion::Eu), ..Default::default() }; let bucket = client.bucket().create(&new_bucket)?;
pub fn read(&self, name: &str) -> Result<Bucket>[src]
pub fn read(&self, name: &str) -> Result<Bucket>[src]Returns a single Bucket by its name. If the Bucket does not exist, an error is returned.
Example
use cloud_storage::sync::Client; use cloud_storage::Bucket; let client = Client::new()?; let bucket = client.bucket().read("cloud-storage-rs-doc-2")?;
pub fn update(&self, bucket: &Bucket) -> Result<Bucket>[src]
pub fn update(&self, bucket: &Bucket) -> Result<Bucket>[src]Update an existing Bucket. If you declare you bucket as mutable, you can edit its fields.
You can then flush your changes to Google Cloud Storage using this method.
Example
use cloud_storage::sync::Client; use cloud_storage::bucket::{Bucket, RetentionPolicy}; let client = Client::new()?; let mut bucket = client.bucket().read("cloud-storage-rs-doc-3")?; bucket.retention_policy = Some(RetentionPolicy { retention_period: 50, effective_time: chrono::Utc::now() + chrono::Duration::seconds(50), is_locked: Some(false), }); client.bucket().update(&bucket)?;
pub fn delete(&self, bucket: Bucket) -> Result<()>[src]
pub fn delete(&self, bucket: Bucket) -> Result<()>[src]Delete an existing Bucket. This permanently removes a bucket from Google Cloud Storage.
An error is returned when you don’t have sufficient permissions, or when the
retention_policy prevents you from deleting your Bucket.
Example
use cloud_storage::sync::Client; use cloud_storage::Bucket; let client = Client::new()?; let bucket = client.bucket().read("unnecessary-bucket")?; client.bucket().delete(bucket)?;
pub fn get_iam_policy(&self, bucket: &Bucket) -> Result<IamPolicy>[src]
pub fn get_iam_policy(&self, bucket: &Bucket) -> Result<IamPolicy>[src]Returns the IAM Policy for this bucket.
Example
use cloud_storage::sync::Client; use cloud_storage::Bucket; let client = Client::new()?; let bucket = client.bucket().read("cloud-storage-rs-doc-4")?; let policy = client.bucket().get_iam_policy(&bucket)?;
pub fn set_iam_policy(
&self,
bucket: &Bucket,
iam: &IamPolicy
) -> Result<IamPolicy>[src]
pub fn set_iam_policy(
&self,
bucket: &Bucket,
iam: &IamPolicy
) -> Result<IamPolicy>[src]Updates the IAM Policy for this bucket.
Example
use cloud_storage::sync::Client; use cloud_storage::Bucket; use cloud_storage::bucket::{IamPolicy, Binding, IamRole, StandardIamRole, Entity}; let client = Client::new()?; let bucket = client.bucket().read("cloud-storage-rs-doc-5")?; let iam_policy = IamPolicy { version: 1, bindings: vec![ Binding { role: IamRole::Standard(StandardIamRole::ObjectViewer), members: vec!["allUsers".to_string()], condition: None, } ], ..Default::default() }; let policy = client.bucket().set_iam_policy(&bucket, &iam_policy)?;
pub fn test_iam_permission(
&self,
bucket: &Bucket,
permission: &str
) -> Result<TestIamPermission>[src]
pub fn test_iam_permission(
&self,
bucket: &Bucket,
permission: &str
) -> Result<TestIamPermission>[src]Checks whether the user provided in the service account has this permission.
Example
use cloud_storage::sync::Client; use cloud_storage::Bucket; let client = Client::new()?; let bucket = client.bucket().read("my-bucket")?; client.bucket().test_iam_permission(&bucket, "storage.buckets.get")?;
Trait Implementations
Auto Trait Implementations
impl<'a> !RefUnwindSafe for BucketClient<'a>
impl<'a> Send for BucketClient<'a>
impl<'a> Sync for BucketClient<'a>
impl<'a> Unpin for BucketClient<'a>
impl<'a> !UnwindSafe for BucketClient<'a>
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]pub fn borrow_mut(&mut self) -> &mut T[src]
pub fn borrow_mut(&mut self) -> &mut T[src]Mutably borrows from an owned value. Read more
impl<T> Instrument for T[src]
impl<T> Instrument for T[src]fn instrument(self, span: Span) -> Instrumented<Self>[src]
fn instrument(self, span: Span) -> Instrumented<Self>[src]Instruments this type with the provided Span, returning an
Instrumented wrapper. Read more
fn in_current_span(self) -> Instrumented<Self>[src]
fn in_current_span(self) -> Instrumented<Self>[src]