google-cloud-storage 1.2.0

Google Cloud Client Libraries for Rust - Storage
Documentation
// Copyright 2025 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by sidekick. DO NOT EDIT.

use crate::control::client::*;

impl StorageControl {
    /// Returns a builder for [StorageControl].
    ///
    /// ```no_run
    /// # tokio_test::block_on(async {
    /// # use google_cloud_storage::client::StorageControl;
    /// let client = StorageControl::builder().build().await?;
    /// # gax::client_builder::Result::<()>::Ok(()) });
    /// ```
    pub fn builder() -> ClientBuilder {
        gax::client_builder::internal::new_builder(client_builder::Factory)
    }

    /// Permanently deletes an empty bucket.
    pub fn delete_bucket(&self) -> crate::builder::storage_control::DeleteBucket {
        self.storage.delete_bucket()
    }

    /// Returns metadata for the specified bucket.
    pub fn get_bucket(&self) -> crate::builder::storage_control::GetBucket {
        self.storage.get_bucket()
    }

    /// Creates a new bucket.
    pub fn create_bucket(&self) -> crate::builder::storage_control::CreateBucket {
        self.storage.create_bucket()
    }

    /// Retrieves a list of buckets for a given project.
    pub fn list_buckets(&self) -> crate::builder::storage_control::ListBuckets {
        self.storage.list_buckets()
    }

    /// Locks retention policy on a bucket.
    pub fn lock_bucket_retention_policy(
        &self,
    ) -> crate::builder::storage_control::LockBucketRetentionPolicy {
        self.storage.lock_bucket_retention_policy()
    }

    /// Updates a bucket. Equivalent to JSON API's storage.buckets.patch method.
    pub fn update_bucket(&self) -> crate::builder::storage_control::UpdateBucket {
        self.storage.update_bucket()
    }

    /// Concatenates a list of existing objects into a new object in the same
    /// bucket.
    pub fn compose_object(&self) -> crate::builder::storage_control::ComposeObject {
        self.storage.compose_object()
    }

    /// Deletes an object and its metadata. Deletions are permanent if versioning
    /// is not enabled for the bucket, or if the generation parameter is used, or
    /// if [soft delete](https://cloud.google.com/storage/docs/soft-delete) is not
    /// enabled for the bucket.
    /// When this API is used to delete an object from a bucket that has soft
    /// delete policy enabled, the object becomes soft deleted, and the
    /// `softDeleteTime` and `hardDeleteTime` properties are set on the object.
    /// This API cannot be used to permanently delete soft-deleted objects.
    /// Soft-deleted objects are permanently deleted according to their
    /// `hardDeleteTime`.
    ///
    /// You can use the [`RestoreObject`][google.storage.v2.Storage.RestoreObject]
    /// API to restore soft-deleted objects until the soft delete retention period
    /// has passed.
    ///
    /// **IAM Permissions**:
    ///
    /// Requires `storage.objects.delete`
    /// [IAM permission](https://cloud.google.com/iam/docs/overview#permissions) on
    /// the bucket.
    ///
    /// [google.storage.v2.Storage.RestoreObject]: crate::client::StorageControl::restore_object
    pub fn delete_object(&self) -> crate::builder::storage_control::DeleteObject {
        self.storage.delete_object()
    }

    /// Restores a soft-deleted object.
    pub fn restore_object(&self) -> crate::builder::storage_control::RestoreObject {
        self.storage.restore_object()
    }

    /// Retrieves object metadata.
    ///
    /// **IAM Permissions**:
    ///
    /// Requires `storage.objects.get`
    /// [IAM permission](https://cloud.google.com/iam/docs/overview#permissions) on
    /// the bucket. To return object ACLs, the authenticated user must also have
    /// the `storage.objects.getIamPolicy` permission.
    pub fn get_object(&self) -> crate::builder::storage_control::GetObject {
        self.storage.get_object()
    }

    /// Updates an object's metadata.
    /// Equivalent to JSON API's storage.objects.patch.
    pub fn update_object(&self) -> crate::builder::storage_control::UpdateObject {
        self.storage.update_object()
    }

    /// Retrieves a list of objects matching the criteria.
    ///
    /// **IAM Permissions**:
    ///
    /// The authenticated user requires `storage.objects.list`
    /// [IAM permission](https://cloud.google.com/iam/docs/overview#permissions)
    /// to use this method. To return object ACLs, the authenticated user must also
    /// have the `storage.objects.getIamPolicy` permission.
    pub fn list_objects(&self) -> crate::builder::storage_control::ListObjects {
        self.storage.list_objects()
    }

    /// Rewrites a source object to a destination object. Optionally overrides
    /// metadata.
    pub fn rewrite_object(&self) -> crate::builder::storage_control::RewriteObject {
        self.storage.rewrite_object()
    }

    /// Moves the source object to the destination object in the same bucket.
    pub fn move_object(&self) -> crate::builder::storage_control::MoveObject {
        self.storage.move_object()
    }

    /// Creates a new folder. This operation is only applicable to a hierarchical
    /// namespace enabled bucket.
    pub fn create_folder(&self) -> crate::builder::storage_control::CreateFolder {
        self.control.create_folder()
    }

    /// Permanently deletes an empty folder. This operation is only applicable to a
    /// hierarchical namespace enabled bucket.
    pub fn delete_folder(&self) -> crate::builder::storage_control::DeleteFolder {
        self.control.delete_folder()
    }

    /// Returns metadata for the specified folder. This operation is only
    /// applicable to a hierarchical namespace enabled bucket.
    pub fn get_folder(&self) -> crate::builder::storage_control::GetFolder {
        self.control.get_folder()
    }

    /// Retrieves a list of folders. This operation is only applicable to a
    /// hierarchical namespace enabled bucket.
    pub fn list_folders(&self) -> crate::builder::storage_control::ListFolders {
        self.control.list_folders()
    }

    /// Renames a source folder to a destination folder. This operation is only
    /// applicable to a hierarchical namespace enabled bucket. During a rename, the
    /// source and destination folders are locked until the long running operation
    /// completes.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn rename_folder(&self) -> crate::builder::storage_control::RenameFolder {
        self.control.rename_folder()
    }

    /// Returns the storage layout configuration for a given bucket.
    pub fn get_storage_layout(&self) -> crate::builder::storage_control::GetStorageLayout {
        self.control.get_storage_layout()
    }

    /// Creates a new managed folder.
    pub fn create_managed_folder(&self) -> crate::builder::storage_control::CreateManagedFolder {
        self.control.create_managed_folder()
    }

    /// Permanently deletes an empty managed folder.
    pub fn delete_managed_folder(&self) -> crate::builder::storage_control::DeleteManagedFolder {
        self.control.delete_managed_folder()
    }

    /// Returns metadata for the specified managed folder.
    pub fn get_managed_folder(&self) -> crate::builder::storage_control::GetManagedFolder {
        self.control.get_managed_folder()
    }

    /// Retrieves a list of managed folders for a given bucket.
    pub fn list_managed_folders(&self) -> crate::builder::storage_control::ListManagedFolders {
        self.control.list_managed_folders()
    }

    /// Creates an Anywhere Cache instance.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn create_anywhere_cache(&self) -> crate::builder::storage_control::CreateAnywhereCache {
        self.control.create_anywhere_cache()
    }

    /// Updates an Anywhere Cache instance. Mutable fields include `ttl` and
    /// `admission_policy`.
    ///
    /// # Long running operations
    ///
    /// This method is used to start, and/or poll a [long-running Operation].
    /// The [Working with long-running operations] chapter in the [user guide]
    /// covers these operations in detail.
    ///
    /// [long-running operation]: https://google.aip.dev/151
    /// [user guide]: https://googleapis.github.io/google-cloud-rust/
    /// [working with long-running operations]: https://googleapis.github.io/google-cloud-rust/working_with_long_running_operations.html
    pub fn update_anywhere_cache(&self) -> crate::builder::storage_control::UpdateAnywhereCache {
        self.control.update_anywhere_cache()
    }

    /// Disables an Anywhere Cache instance. A disabled instance is read-only. The
    /// disablement could be revoked by calling ResumeAnywhereCache. The cache
    /// instance will be deleted automatically if it remains in the disabled state
    /// for at least one hour.
    pub fn disable_anywhere_cache(&self) -> crate::builder::storage_control::DisableAnywhereCache {
        self.control.disable_anywhere_cache()
    }

    /// Pauses an Anywhere Cache instance.
    pub fn pause_anywhere_cache(&self) -> crate::builder::storage_control::PauseAnywhereCache {
        self.control.pause_anywhere_cache()
    }

    /// Resumes a disabled or paused Anywhere Cache instance.
    pub fn resume_anywhere_cache(&self) -> crate::builder::storage_control::ResumeAnywhereCache {
        self.control.resume_anywhere_cache()
    }

    /// Gets an Anywhere Cache instance.
    pub fn get_anywhere_cache(&self) -> crate::builder::storage_control::GetAnywhereCache {
        self.control.get_anywhere_cache()
    }

    /// Lists Anywhere Cache instances for a given bucket.
    pub fn list_anywhere_caches(&self) -> crate::builder::storage_control::ListAnywhereCaches {
        self.control.list_anywhere_caches()
    }

    /// Returns the Project scoped singleton IntelligenceConfig resource.
    pub fn get_project_intelligence_config(
        &self,
    ) -> crate::builder::storage_control::GetProjectIntelligenceConfig {
        self.control.get_project_intelligence_config()
    }

    /// Updates the Project scoped singleton IntelligenceConfig resource.
    pub fn update_project_intelligence_config(
        &self,
    ) -> crate::builder::storage_control::UpdateProjectIntelligenceConfig {
        self.control.update_project_intelligence_config()
    }

    /// Returns the Folder scoped singleton IntelligenceConfig resource.
    pub fn get_folder_intelligence_config(
        &self,
    ) -> crate::builder::storage_control::GetFolderIntelligenceConfig {
        self.control.get_folder_intelligence_config()
    }

    /// Updates the Folder scoped singleton IntelligenceConfig resource.
    pub fn update_folder_intelligence_config(
        &self,
    ) -> crate::builder::storage_control::UpdateFolderIntelligenceConfig {
        self.control.update_folder_intelligence_config()
    }

    /// Returns the Organization scoped singleton IntelligenceConfig resource.
    pub fn get_organization_intelligence_config(
        &self,
    ) -> crate::builder::storage_control::GetOrganizationIntelligenceConfig {
        self.control.get_organization_intelligence_config()
    }

    /// Updates the Organization scoped singleton IntelligenceConfig resource.
    pub fn update_organization_intelligence_config(
        &self,
    ) -> crate::builder::storage_control::UpdateOrganizationIntelligenceConfig {
        self.control.update_organization_intelligence_config()
    }

    /// Gets the IAM policy for a specified bucket.
    /// The `resource` field in the request should be
    /// `projects/_/buckets/{bucket}` for a bucket, or
    /// `projects/_/buckets/{bucket}/managedFolders/{managedFolder}`
    /// for a managed folder.
    pub fn get_iam_policy(&self) -> crate::builder::storage_control::GetIamPolicy {
        self.control.get_iam_policy()
    }

    /// Updates an IAM policy for the specified bucket.
    /// The `resource` field in the request should be
    /// `projects/_/buckets/{bucket}` for a bucket, or
    /// `projects/_/buckets/{bucket}/managedFolders/{managedFolder}`
    /// for a managed folder.
    pub fn set_iam_policy(&self) -> crate::builder::storage_control::SetIamPolicy {
        self.control.set_iam_policy()
    }

    /// Tests a set of permissions on the given bucket, object, or managed folder
    /// to see which, if any, are held by the caller.
    /// The `resource` field in the request should be
    /// `projects/_/buckets/{bucket}` for a bucket,
    /// `projects/_/buckets/{bucket}/objects/{object}` for an object, or
    /// `projects/_/buckets/{bucket}/managedFolders/{managedFolder}`
    /// for a managed folder.
    pub fn test_iam_permissions(&self) -> crate::builder::storage_control::TestIamPermissions {
        self.control.test_iam_permissions()
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: longrunning::client::Operations
    pub fn get_operation(&self) -> crate::builder::storage_control::GetOperation {
        self.control.get_operation()
    }

    /// Creates a new client from the provided stub.
    ///
    /// The most common case for calling this function is in tests mocking the
    /// client's behavior.
    pub fn from_stub<T>(stub: T) -> Self
    where
        T: crate::stub::StorageControl + 'static,
    {
        let stub = std::sync::Arc::new(stub);
        Self {
            storage: crate::generated::gapic::client::StorageControl::from_stub(stub.clone()),
            control: crate::generated::gapic_control::client::StorageControl::from_stub(stub),
        }
    }

    pub(crate) async fn new(
        config: gaxi::options::ClientConfig,
    ) -> gax::client_builder::Result<Self> {
        let storage = crate::generated::gapic::client::StorageControl::new(config.clone()).await?;
        let control = crate::generated::gapic_control::client::StorageControl::new(config).await?;
        Ok(Self { storage, control })
    }
}