Struct google_cloud_storage::client::Client
source · pub struct Client { /* private fields */ }Implementations
sourceimpl Client
impl Client
sourcepub async fn new(config: ClientConfig) -> Result<Self, Error>
pub async fn new(config: ClientConfig) -> Result<Self, Error>
New client
sourcepub fn project_id(&self) -> &str
pub fn project_id(&self) -> &str
Gets the project_id from Credentials
sourcepub async fn signed_url(
&self,
bucket: &str,
object: &str,
opts: SignedURLOptions
) -> Result<String, SignedURLError>
pub async fn signed_url(
&self,
bucket: &str,
object: &str,
opts: SignedURLOptions
) -> Result<String, SignedURLError>
Get signed url. SignedURL returns a URL for the specified object. Signed URLs allow anyone access to a restricted resource for a limited time without needing a Google account or signing in. For more information about signed URLs, see https://cloud.google.com/storage/docs/accesscontrol#signed_urls_query_string_authentication
use google_cloud_storage::client::Client;
use google_cloud_storage::sign::{SignedURLOptions, SignedURLMethod};
#[tokio::main]
async fn main() {
let client = Client::default().await.unwrap();
let url_for_download = client.signed_url("bucket", "file.txt", SignedURLOptions::default()).await;
let url_for_upload = client.signed_url("bucket", "file.txt", SignedURLOptions {
method: SignedURLMethod::PUT,
..Default::default()
}).await;
}Methods from Deref<Target = StorageClient>
sourcepub async fn delete_bucket(
&self,
req: &DeleteBucketRequest,
cancel: Option<CancellationToken>
) -> Result<(), Error>
pub async fn delete_bucket(
&self,
req: &DeleteBucketRequest,
cancel: Option<CancellationToken>
) -> Result<(), Error>
Deletes the bucket. https://cloud.google.com/storage/docs/json_api/v1/buckets/delete
use google_cloud_storage::client::Client;
use google_cloud_storage::http::buckets::delete::DeleteBucketRequest;
#[tokio::main]
async fn main() {
let client = Client::default().await.unwrap();
let result = client.delete_bucket(&DeleteBucketRequest {
bucket: "bucket".to_string(),
..Default::default()
}, None).await;
}sourcepub async fn insert_bucket(
&self,
req: &InsertBucketRequest,
cancel: Option<CancellationToken>
) -> Result<Bucket, Error>
pub async fn insert_bucket(
&self,
req: &InsertBucketRequest,
cancel: Option<CancellationToken>
) -> Result<Bucket, Error>
Inserts the bucket. https://cloud.google.com/storage/docs/json_api/v1/buckets/insert
use google_cloud_storage::client::Client;
use google_cloud_storage::http::buckets::insert::{BucketCreationConfig, InsertBucketParam, InsertBucketRequest};
#[tokio::main]
async fn main() {
let client = Client::default().await.unwrap();
let result = client.insert_bucket(&InsertBucketRequest {
name: "bucket".to_string(),
param: InsertBucketParam {
project: client.project_id().to_string(),
..Default::default()
},
..Default::default()
}, None).await;
}sourcepub async fn get_bucket(
&self,
req: &GetBucketRequest,
cancel: Option<CancellationToken>
) -> Result<Bucket, Error>
pub async fn get_bucket(
&self,
req: &GetBucketRequest,
cancel: Option<CancellationToken>
) -> Result<Bucket, Error>
Gets the bucket. https://cloud.google.com/storage/docs/json_api/v1/buckets/get
use google_cloud_storage::client::Client;
use google_cloud_storage::http::buckets::get::GetBucketRequest;
#[tokio::main]
async fn main() {
let client = Client::default().await.unwrap();
let result = client.get_bucket(&GetBucketRequest {
bucket: "bucket".to_string(),
..Default::default()
}, None).await;
}sourcepub async fn patch_bucket(
&self,
req: &PatchBucketRequest,
cancel: Option<CancellationToken>
) -> Result<Bucket, Error>
pub async fn patch_bucket(
&self,
req: &PatchBucketRequest,
cancel: Option<CancellationToken>
) -> Result<Bucket, Error>
Patches the bucket. https://cloud.google.com/storage/docs/json_api/v1/buckets/patch
use google_cloud_storage::client::Client;
use google_cloud_storage::http::buckets::patch::{BucketPatchConfig, PatchBucketRequest};
#[tokio::main]
async fn main() {
let client = Client::default().await.unwrap();
let result = client.patch_bucket(&PatchBucketRequest {
bucket: "bucket".to_string(),
metadata: Some(BucketPatchConfig {
..Default::default()
}),
..Default::default()
}, None).await;
}sourcepub async fn list_buckets(
&self,
req: &ListBucketsRequest,
cancel: Option<CancellationToken>
) -> Result<ListBucketsResponse, Error>
pub async fn list_buckets(
&self,
req: &ListBucketsRequest,
cancel: Option<CancellationToken>
) -> Result<ListBucketsResponse, Error>
Lists the bucket. https://cloud.google.com/storage/docs/json_api/v1/buckets/list
use google_cloud_storage::client::Client;
use google_cloud_storage::http::buckets::list::ListBucketsRequest;
#[tokio::main]
async fn main() {
let client = Client::default().await.unwrap();
let result = client.list_buckets(&ListBucketsRequest{
project: client.project_id().to_string(),
..Default::default()
}, None).await;
}sourcepub async fn set_iam_policy(
&self,
req: &SetIamPolicyRequest,
cancel: Option<CancellationToken>
) -> Result<Policy, Error>
pub async fn set_iam_policy(
&self,
req: &SetIamPolicyRequest,
cancel: Option<CancellationToken>
) -> Result<Policy, Error>
Sets the iam policy. https://cloud.google.com/storage/docs/json_api/v1/buckets/setIamPolicy
use google_cloud_storage::client::Client;
use google_cloud_storage::http::buckets::{Binding, Policy};
use google_cloud_storage::http::buckets::set_iam_policy::SetIamPolicyRequest;
#[tokio::main]
async fn main() {
let client = Client::default().await.unwrap();
let result = client.set_iam_policy(&SetIamPolicyRequest{
resource: "bucket".to_string(),
policy: Policy {
bindings: vec![Binding {
role: "roles/storage.objectViewer".to_string(),
members: vec!["allAuthenticatedUsers".to_string()],
condition: None,
}],
..Default::default()
},
..Default::default()
}, None).await;
}sourcepub async fn get_iam_policy(
&self,
req: &GetIamPolicyRequest,
cancel: Option<CancellationToken>
) -> Result<Policy, Error>
pub async fn get_iam_policy(
&self,
req: &GetIamPolicyRequest,
cancel: Option<CancellationToken>
) -> Result<Policy, Error>
Gets the iam policy. https://cloud.google.com/storage/docs/json_api/v1/buckets/getIamPolicy
use google_cloud_storage::client::Client;
use google_cloud_storage::http::buckets::get_iam_policy::GetIamPolicyRequest;
use google_cloud_storage::http::buckets::list::ListBucketsRequest;
#[tokio::main]
async fn main() {
let client = Client::default().await.unwrap();
let result = client.get_iam_policy(&GetIamPolicyRequest{
resource: "bucket".to_string(),
..Default::default()
}, None).await;
}sourcepub async fn test_iam_permissions(
&self,
req: &TestIamPermissionsRequest,
cancel: Option<CancellationToken>
) -> Result<TestIamPermissionsResponse, Error>
pub async fn test_iam_permissions(
&self,
req: &TestIamPermissionsRequest,
cancel: Option<CancellationToken>
) -> Result<TestIamPermissionsResponse, Error>
Tests the iam permissions. https://cloud.google.com/storage/docs/json_api/v1/buckets/testIamPermissions
use google_cloud_storage::client::Client;
use google_cloud_storage::http::buckets::test_iam_permissions::TestIamPermissionsRequest;
#[tokio::main]
async fn main() {
let client = Client::default().await.unwrap();
let result = client.test_iam_permissions(&TestIamPermissionsRequest{
resource: "bucket".to_string(),
permissions: vec!["storage.buckets.get".to_string()],
}, None).await;
}sourcepub async fn list_default_object_access_controls(
&self,
req: &ListDefaultObjectAccessControlsRequest,
cancel: Option<CancellationToken>
) -> Result<ListDefaultObjectAccessControlsResponse, Error>
pub async fn list_default_object_access_controls(
&self,
req: &ListDefaultObjectAccessControlsRequest,
cancel: Option<CancellationToken>
) -> Result<ListDefaultObjectAccessControlsResponse, Error>
Lists the default object ACL. https://cloud.google.com/storage/docs/json_api/v1/defaultObjectAccessControls/list
use google_cloud_storage::client::Client;
use google_cloud_storage::http::buckets::test_iam_permissions::TestIamPermissionsRequest;
use google_cloud_storage::http::default_object_access_controls::list::ListDefaultObjectAccessControlsRequest;
#[tokio::main]
async fn main() {
let client = Client::default().await.unwrap();
let result = client.list_default_object_access_controls(&ListDefaultObjectAccessControlsRequest{
bucket: "bucket".to_string(),
..Default::default()
}, None).await;
}sourcepub async fn get_default_object_access_control(
&self,
req: &GetDefaultObjectAccessControlRequest,
cancel: Option<CancellationToken>
) -> Result<ObjectAccessControl, Error>
pub async fn get_default_object_access_control(
&self,
req: &GetDefaultObjectAccessControlRequest,
cancel: Option<CancellationToken>
) -> Result<ObjectAccessControl, Error>
Gets the default object ACL. https://cloud.google.com/storage/docs/json_api/v1/defaultObjectAccessControls/get
use google_cloud_storage::client::Client;
use google_cloud_storage::http::default_object_access_controls::get::GetDefaultObjectAccessControlRequest;
#[tokio::main]
async fn main() {
let client = Client::default().await.unwrap();
let result = client.get_default_object_access_control(&GetDefaultObjectAccessControlRequest{
bucket: "bucket".to_string(),
entity: "allAuthenticatedUsers".to_string(),
}, None).await;
}sourcepub async fn insert_default_object_access_control(
&self,
req: &InsertDefaultObjectAccessControlRequest,
cancel: Option<CancellationToken>
) -> Result<ObjectAccessControl, Error>
pub async fn insert_default_object_access_control(
&self,
req: &InsertDefaultObjectAccessControlRequest,
cancel: Option<CancellationToken>
) -> Result<ObjectAccessControl, Error>
Inserts the default object ACL. https://cloud.google.com/storage/docs/json_api/v1/defaultObjectAccessControls/insert
use google_cloud_storage::client::Client;
use google_cloud_storage::http::default_object_access_controls::insert::InsertDefaultObjectAccessControlRequest;
use google_cloud_storage::http::object_access_controls::insert::ObjectAccessControlCreationConfig;
use google_cloud_storage::http::object_access_controls::ObjectACLRole;
#[tokio::main]
async fn main() {
let client = Client::default().await.unwrap();
let result = client.insert_default_object_access_control(&InsertDefaultObjectAccessControlRequest{
bucket: "bucket".to_string(),
object_access_control: ObjectAccessControlCreationConfig {
entity: "allAuthenticatedUsers".to_string(),
role: ObjectACLRole::READER
} ,
}, None).await;
}sourcepub async fn patch_default_object_access_control(
&self,
req: &PatchDefaultObjectAccessControlRequest,
cancel: Option<CancellationToken>
) -> Result<ObjectAccessControl, Error>
pub async fn patch_default_object_access_control(
&self,
req: &PatchDefaultObjectAccessControlRequest,
cancel: Option<CancellationToken>
) -> Result<ObjectAccessControl, Error>
Patches the default object ACL. https://cloud.google.com/storage/docs/json_api/v1/defaultObjectAccessControls/patch
use google_cloud_storage::client::Client;
use google_cloud_storage::http::default_object_access_controls::patch::PatchDefaultObjectAccessControlRequest;
use google_cloud_storage::http::object_access_controls::insert::ObjectAccessControlCreationConfig;
use google_cloud_storage::http::object_access_controls::{ObjectAccessControl, ObjectACLRole};
use google_cloud_storage::http::object_access_controls::patch::PatchObjectAccessControlRequest;
#[tokio::main]
async fn main() {
let client = Client::default().await.unwrap();
let result = client.patch_default_object_access_control(&PatchDefaultObjectAccessControlRequest{
bucket: "bucket".to_string(),
entity: "allAuthenticatedUsers".to_string(),
object_access_control: ObjectAccessControl {
role: ObjectACLRole::READER,
..Default::default()
},
}, None).await;
}sourcepub async fn delete_default_object_access_control(
&self,
req: &DeleteDefaultObjectAccessControlRequest,
cancel: Option<CancellationToken>
) -> Result<(), Error>
pub async fn delete_default_object_access_control(
&self,
req: &DeleteDefaultObjectAccessControlRequest,
cancel: Option<CancellationToken>
) -> Result<(), Error>
Deletes the default object ACL. https://cloud.google.com/storage/docs/json_api/v1/defaultObjectAccessControls/delete
use google_cloud_storage::client::Client;
use google_cloud_storage::http::default_object_access_controls::delete::DeleteDefaultObjectAccessControlRequest;
#[tokio::main]
async fn main() {
let client = Client::default().await.unwrap();
let result = client.delete_default_object_access_control(&DeleteDefaultObjectAccessControlRequest{
bucket: "bucket".to_string(),
entity: "allAuthenticatedUsers".to_string(),
}, None).await;
}sourcepub async fn list_bucket_access_controls(
&self,
req: &ListBucketAccessControlsRequest,
cancel: Option<CancellationToken>
) -> Result<ListBucketAccessControlsResponse, Error>
pub async fn list_bucket_access_controls(
&self,
req: &ListBucketAccessControlsRequest,
cancel: Option<CancellationToken>
) -> Result<ListBucketAccessControlsResponse, Error>
Lists the bucket ACL. https://cloud.google.com/storage/docs/json_api/v1/bucketAccessControls/list
use google_cloud_storage::client::Client;
use google_cloud_storage::http::bucket_access_controls::list::ListBucketAccessControlsRequest;
#[tokio::main]
async fn main() {
let client = Client::default().await.unwrap();
let result = client.list_bucket_access_controls(&ListBucketAccessControlsRequest{
bucket: "bucket".to_string(),
}, None).await;
}sourcepub async fn get_bucket_access_control(
&self,
req: &GetBucketAccessControlRequest,
cancel: Option<CancellationToken>
) -> Result<BucketAccessControl, Error>
pub async fn get_bucket_access_control(
&self,
req: &GetBucketAccessControlRequest,
cancel: Option<CancellationToken>
) -> Result<BucketAccessControl, Error>
Gets the bucket ACL. https://cloud.google.com/storage/docs/json_api/v1/bucketAccessControls/get
use google_cloud_storage::client::Client;
use google_cloud_storage::http::bucket_access_controls::get::GetBucketAccessControlRequest;
#[tokio::main]
async fn main() {
let client = Client::default().await.unwrap();
let result = client.get_bucket_access_control(&GetBucketAccessControlRequest{
bucket: "bucket".to_string(),
entity: "allAuthenticatedUsers".to_string(),
}, None).await;
}sourcepub async fn insert_bucket_access_control(
&self,
req: &InsertBucketAccessControlRequest,
cancel: Option<CancellationToken>
) -> Result<BucketAccessControl, Error>
pub async fn insert_bucket_access_control(
&self,
req: &InsertBucketAccessControlRequest,
cancel: Option<CancellationToken>
) -> Result<BucketAccessControl, Error>
Inserts the bucket ACL. https://cloud.google.com/storage/docs/json_api/v1/bucketAccessControls/insert
use google_cloud_storage::client::Client;
use google_cloud_storage::http::bucket_access_controls::BucketACLRole;
use google_cloud_storage::http::bucket_access_controls::insert::{BucketAccessControlCreationConfig, InsertBucketAccessControlRequest};
#[tokio::main]
async fn main() {
let client = Client::default().await.unwrap();
let result = client.insert_bucket_access_control(&InsertBucketAccessControlRequest{
bucket: "bucket".to_string(),
acl: BucketAccessControlCreationConfig {
entity: "allAuthenticatedUsers".to_string(),
role: BucketACLRole::READER
}
}, None).await;
}sourcepub async fn patch_bucket_access_control(
&self,
req: &PatchBucketAccessControlRequest,
cancel: Option<CancellationToken>
) -> Result<BucketAccessControl, Error>
pub async fn patch_bucket_access_control(
&self,
req: &PatchBucketAccessControlRequest,
cancel: Option<CancellationToken>
) -> Result<BucketAccessControl, Error>
Patches the bucket ACL. https://cloud.google.com/storage/docs/json_api/v1/bucketAccessControls/patch
use google_cloud_storage::client::Client;
use google_cloud_storage::http::bucket_access_controls::BucketAccessControl;
use google_cloud_storage::http::bucket_access_controls::BucketACLRole;
use google_cloud_storage::http::bucket_access_controls::patch::PatchBucketAccessControlRequest;
#[tokio::main]
async fn main() {
let client = Client::default().await.unwrap();
let result = client.patch_bucket_access_control(&PatchBucketAccessControlRequest{
bucket: "bucket".to_string(),
entity: "allAuthenticatedUsers".to_string(),
acl: BucketAccessControl {
role: BucketACLRole::READER,
..Default::default()
}
}, None).await;
}sourcepub async fn delete_bucket_access_control(
&self,
req: &DeleteBucketAccessControlRequest,
cancel: Option<CancellationToken>
) -> Result<(), Error>
pub async fn delete_bucket_access_control(
&self,
req: &DeleteBucketAccessControlRequest,
cancel: Option<CancellationToken>
) -> Result<(), Error>
Deletes the bucket ACL.
use google_cloud_storage::client::Client;
use google_cloud_storage::http::bucket_access_controls::BucketAccessControl;
use google_cloud_storage::http::bucket_access_controls::delete::DeleteBucketAccessControlRequest;
#[tokio::main]
async fn main() {
let client = Client::default().await.unwrap();
let result = client.delete_bucket_access_control(&DeleteBucketAccessControlRequest{
bucket: "bucket".to_string(),
entity: "allAuthenticatedUsers".to_string(),
}, None).await;
}pub async fn _delete_bucket_access_control(
&self,
req: &DeleteBucketAccessControlRequest,
cancel: Option<CancellationToken>
) -> Result<(), Error>
sourcepub async fn list_object_access_controls(
&self,
req: &ListObjectAccessControlsRequest,
cancel: Option<CancellationToken>
) -> Result<ListBucketAccessControlsResponse, Error>
pub async fn list_object_access_controls(
&self,
req: &ListObjectAccessControlsRequest,
cancel: Option<CancellationToken>
) -> Result<ListBucketAccessControlsResponse, Error>
Lists the object ACL. https://cloud.google.com/storage/docs/json_api/v1/objectAccessControls/list
use google_cloud_storage::client::Client;
use google_cloud_storage::http::object_access_controls::list::ListObjectAccessControlsRequest;
#[tokio::main]
async fn main() {
let client = Client::default().await.unwrap();
let result = client.list_object_access_controls(&ListObjectAccessControlsRequest{
bucket: "bucket".to_string(),
object: "filename".to_string(),
..Default::default()
}, None).await;
}sourcepub async fn get_object_access_control(
&self,
req: &GetObjectAccessControlRequest,
cancel: Option<CancellationToken>
) -> Result<ObjectAccessControl, Error>
pub async fn get_object_access_control(
&self,
req: &GetObjectAccessControlRequest,
cancel: Option<CancellationToken>
) -> Result<ObjectAccessControl, Error>
Gets the object ACL. https://cloud.google.com/storage/docs/json_api/v1/objectAccessControls/get
use google_cloud_storage::client::Client;
use google_cloud_storage::http::object_access_controls::get::GetObjectAccessControlRequest;
#[tokio::main]
async fn main() {
let client = Client::default().await.unwrap();
let result = client.get_object_access_control(&GetObjectAccessControlRequest{
bucket: "bucket".to_string(),
object: "filename".to_string(),
entity: "allAuthenticatedUsers".to_string(),
..Default::default()
}, None).await;
}sourcepub async fn insert_object_access_control(
&self,
req: &InsertObjectAccessControlRequest,
cancel: Option<CancellationToken>
) -> Result<ObjectAccessControl, Error>
pub async fn insert_object_access_control(
&self,
req: &InsertObjectAccessControlRequest,
cancel: Option<CancellationToken>
) -> Result<ObjectAccessControl, Error>
Inserts the object ACL. https://cloud.google.com/storage/docs/json_api/v1/objectAccessControls/insert
use google_cloud_storage::client::Client;
use google_cloud_storage::http::object_access_controls::insert::{InsertObjectAccessControlRequest, ObjectAccessControlCreationConfig};
use google_cloud_storage::http::object_access_controls::ObjectACLRole;
#[tokio::main]
async fn main() {
let client = Client::default().await.unwrap();
let result = client.insert_object_access_control(&InsertObjectAccessControlRequest{
bucket: "bucket".to_string(),
object: "filename".to_string(),
acl: ObjectAccessControlCreationConfig {
entity: "allAuthenticatedUsers".to_string(),
role: ObjectACLRole::READER
},
..Default::default()
}, None).await;
}sourcepub async fn patch_object_access_control(
&self,
req: &PatchObjectAccessControlRequest,
cancel: Option<CancellationToken>
) -> Result<ObjectAccessControl, Error>
pub async fn patch_object_access_control(
&self,
req: &PatchObjectAccessControlRequest,
cancel: Option<CancellationToken>
) -> Result<ObjectAccessControl, Error>
Patches the bucket ACL. https://cloud.google.com/storage/docs/json_api/v1/objectAccessControls/patch
use google_cloud_storage::client::Client;
use google_cloud_storage::http::object_access_controls::{ObjectAccessControl, ObjectACLRole};
use google_cloud_storage::http::object_access_controls::patch::PatchObjectAccessControlRequest;
#[tokio::main]
async fn main() {
let client = Client::default().await.unwrap();
let result = client.patch_object_access_control(&PatchObjectAccessControlRequest{
bucket: "bucket".to_string(),
object: "filename".to_string(),
entity: "allAuthenticatedUsers".to_string(),
acl: ObjectAccessControl {
role: ObjectACLRole::READER,
..Default::default()
},
..Default::default()
}, None).await;
}pub async fn _patch_object_access_control(
&self,
req: &PatchObjectAccessControlRequest,
cancel: Option<CancellationToken>
) -> Result<ObjectAccessControl, Error>
sourcepub async fn delete_object_access_control(
&self,
req: &DeleteObjectAccessControlRequest,
cancel: Option<CancellationToken>
) -> Result<(), Error>
pub async fn delete_object_access_control(
&self,
req: &DeleteObjectAccessControlRequest,
cancel: Option<CancellationToken>
) -> Result<(), Error>
Deletes the bucket ACL. https://cloud.google.com/storage/docs/json_api/v1/objectAccessControls/delete
use google_cloud_storage::client::Client;
use google_cloud_storage::http::object_access_controls::{ObjectAccessControl, ObjectACLRole};
use google_cloud_storage::http::object_access_controls::delete::DeleteObjectAccessControlRequest;
#[tokio::main]
async fn main() {
let client = Client::default().await.unwrap();
let result = client.delete_object_access_control(&DeleteObjectAccessControlRequest{
bucket: "bucket".to_string(),
object: "filename".to_string(),
entity: "allAuthenticatedUsers".to_string(),
..Default::default()
}, None).await;
}sourcepub async fn list_notifications(
&self,
req: &ListNotificationsRequest,
cancel: Option<CancellationToken>
) -> Result<ListNotificationsResponse, Error>
pub async fn list_notifications(
&self,
req: &ListNotificationsRequest,
cancel: Option<CancellationToken>
) -> Result<ListNotificationsResponse, Error>
Lists the notification. https://cloud.google.com/storage/docs/json_api/v1/notifications/list
use google_cloud_storage::client::Client;
use google_cloud_storage::http::notifications::list::ListNotificationsRequest;
#[tokio::main]
async fn main() {
let client = Client::default().await.unwrap();
let result = client.list_notifications(&ListNotificationsRequest{
bucket: "bucket".to_string(),
..Default::default()
}, None).await;
}sourcepub async fn get_notification(
&self,
req: &GetNotificationRequest,
cancel: Option<CancellationToken>
) -> Result<Notification, Error>
pub async fn get_notification(
&self,
req: &GetNotificationRequest,
cancel: Option<CancellationToken>
) -> Result<Notification, Error>
Gets the notification. https://cloud.google.com/storage/docs/json_api/v1/notifications/get
use google_cloud_storage::client::Client;
use google_cloud_storage::http::notifications::get::GetNotificationRequest;
#[tokio::main]
async fn main() {
let client = Client::default().await.unwrap();
let result = client.get_notification(&GetNotificationRequest{
bucket: "bucket".to_string(),
notification: "notification".to_string()
}, None).await;
}sourcepub async fn insert_notification(
&self,
req: &InsertNotificationRequest,
cancel: Option<CancellationToken>
) -> Result<Notification, Error>
pub async fn insert_notification(
&self,
req: &InsertNotificationRequest,
cancel: Option<CancellationToken>
) -> Result<Notification, Error>
Inserts the notification. https://cloud.google.com/storage/docs/json_api/v1/notifications/insert
use google_cloud_storage::client::Client;
use google_cloud_storage::http::notifications::EventType;
use google_cloud_storage::http::notifications::insert::{InsertNotificationRequest, NotificationCreationConfig};
#[tokio::main]
async fn main() {
let client = Client::default().await.unwrap();
let result = client.insert_notification(&InsertNotificationRequest {
bucket: "bucket".to_string(),
notification: NotificationCreationConfig {
topic: format!("projects/{}/topics/{}", "project","bucket"),
event_types: Some(vec![EventType::ObjectMetadataUpdate, EventType::ObjectDelete]),
..Default::default()
}
}, None).await;
}sourcepub async fn delete_notification(
&self,
req: &DeleteNotificationRequest,
cancel: Option<CancellationToken>
) -> Result<(), Error>
pub async fn delete_notification(
&self,
req: &DeleteNotificationRequest,
cancel: Option<CancellationToken>
) -> Result<(), Error>
Deletes the notification. https://cloud.google.com/storage/docs/json_api/v1/notifications/delete
use google_cloud_storage::client::Client;
use google_cloud_storage::http::notifications::delete::DeleteNotificationRequest;
#[tokio::main]
async fn main() {
let client = Client::default().await.unwrap();
let result = client.delete_notification(&DeleteNotificationRequest {
bucket: "bucket".to_string(),
notification: "notification".to_string()
}, None).await;
}sourcepub async fn list_hmac_keys(
&self,
req: &ListHmacKeysRequest,
cancel: Option<CancellationToken>
) -> Result<ListHmacKeysResponse, Error>
pub async fn list_hmac_keys(
&self,
req: &ListHmacKeysRequest,
cancel: Option<CancellationToken>
) -> Result<ListHmacKeysResponse, Error>
Lists the hmac keys. https://cloud.google.com/storage/docs/json_api/v1/projects/hmacKeys/list
use google_cloud_storage::client::Client;
use google_cloud_storage::http::hmac_keys::list::ListHmacKeysRequest;
#[tokio::main]
async fn main() {
let client = Client::default().await.unwrap();
let result = client.list_hmac_keys(&ListHmacKeysRequest {
project_id: client.project_id().to_string(),
..Default::default()
}, None).await;
}sourcepub async fn get_hmac_key(
&self,
req: &GetHmacKeyRequest,
cancel: Option<CancellationToken>
) -> Result<HmacKeyMetadata, Error>
pub async fn get_hmac_key(
&self,
req: &GetHmacKeyRequest,
cancel: Option<CancellationToken>
) -> Result<HmacKeyMetadata, Error>
Gets the hmac keys. https://cloud.google.com/storage/docs/json_api/v1/projects/hmacKeys/get
use google_cloud_storage::client::Client;
use google_cloud_storage::http::hmac_keys::get::GetHmacKeyRequest;
#[tokio::main]
async fn main() {
let client = Client::default().await.unwrap();
let result = client.get_hmac_key(&GetHmacKeyRequest {
access_id: "access_id".to_string(),
project_id: client.project_id().to_string(),
}, None).await;
}sourcepub async fn create_hmac_key(
&self,
req: &CreateHmacKeyRequest,
cancel: Option<CancellationToken>
) -> Result<CreateHmacKeyResponse, Error>
pub async fn create_hmac_key(
&self,
req: &CreateHmacKeyRequest,
cancel: Option<CancellationToken>
) -> Result<CreateHmacKeyResponse, Error>
Creates the hmac key. https://cloud.google.com/storage/docs/json_api/v1/projects/hmacKeys/create
use google_cloud_storage::client::Client;
use google_cloud_storage::http::hmac_keys::create::CreateHmacKeyRequest;
#[tokio::main]
async fn main() {
let client = Client::default().await.unwrap();
let result = client.create_hmac_key(&CreateHmacKeyRequest {
service_account_email: "service_account_email".to_string(),
project_id: client.project_id().to_string(),
}, None).await;
}sourcepub async fn update_hmac_key(
&self,
req: &UpdateHmacKeyRequest,
cancel: Option<CancellationToken>
) -> Result<HmacKeyMetadata, Error>
pub async fn update_hmac_key(
&self,
req: &UpdateHmacKeyRequest,
cancel: Option<CancellationToken>
) -> Result<HmacKeyMetadata, Error>
Updates the hmac key. https://cloud.google.com/storage/docs/json_api/v1/projects/hmacKeys/update
use google_cloud_storage::client::Client;
use google_cloud_storage::http::hmac_keys::HmacKeyMetadata;
use google_cloud_storage::http::hmac_keys::update::UpdateHmacKeyRequest;
#[tokio::main]
async fn main() {
let client = Client::default().await.unwrap();
let result = client.update_hmac_key(&UpdateHmacKeyRequest{
access_id: "access_id".to_string(),
project_id: client.project_id().to_string(),
metadata: HmacKeyMetadata {
state: "INACTIVE".to_string(),
..Default::default()
},
}, None).await;
}sourcepub async fn delete_hmac_key(
&self,
req: &DeleteHmacKeyRequest,
cancel: Option<CancellationToken>
) -> Result<(), Error>
pub async fn delete_hmac_key(
&self,
req: &DeleteHmacKeyRequest,
cancel: Option<CancellationToken>
) -> Result<(), Error>
Deletes the hmac key. https://cloud.google.com/storage/docs/json_api/v1/projects/hmacKeys/delete
use google_cloud_storage::client::Client;
use google_cloud_storage::http::hmac_keys::delete::DeleteHmacKeyRequest;
#[tokio::main]
async fn main() {
let client = Client::default().await.unwrap();
let result = client.delete_hmac_key(&DeleteHmacKeyRequest{
access_id: "access_id".to_string(),
project_id: client.project_id().to_string(),
}, None).await;
}sourcepub async fn list_objects(
&self,
req: &ListObjectsRequest,
cancel: Option<CancellationToken>
) -> Result<ListObjectsResponse, Error>
pub async fn list_objects(
&self,
req: &ListObjectsRequest,
cancel: Option<CancellationToken>
) -> Result<ListObjectsResponse, Error>
Lists the objects. https://cloud.google.com/storage/docs/json_api/v1/objects/list
use google_cloud_storage::client::Client;
use google_cloud_storage::http::objects::list::ListObjectsRequest;
#[tokio::main]
async fn main() {
let client = Client::default().await.unwrap();
let result = client.list_objects(&ListObjectsRequest{
bucket: "bucket".to_string(),
..Default::default()
}, None).await;
}sourcepub async fn get_object(
&self,
req: &GetObjectRequest,
cancel: Option<CancellationToken>
) -> Result<Object, Error>
pub async fn get_object(
&self,
req: &GetObjectRequest,
cancel: Option<CancellationToken>
) -> Result<Object, Error>
Gets the object. https://cloud.google.com/storage/docs/json_api/v1/objects/get
use google_cloud_storage::client::Client;
use google_cloud_storage::http::objects::get::GetObjectRequest;
#[tokio::main]
async fn main() {
let client = Client::default().await.unwrap();
let result = client.get_object(&GetObjectRequest{
bucket: "bucket".to_string(),
object: "object".to_string(),
..Default::default()
}, None).await;
}sourcepub async fn download_object(
&self,
req: &GetObjectRequest,
range: &Range,
cancel: Option<CancellationToken>
) -> Result<Vec<u8>, Error>
pub async fn download_object(
&self,
req: &GetObjectRequest,
range: &Range,
cancel: Option<CancellationToken>
) -> Result<Vec<u8>, Error>
Download the object. https://cloud.google.com/storage/docs/json_api/v1/objects/get alt is always media
use google_cloud_storage::client::Client;
use google_cloud_storage::http::objects::get::GetObjectRequest;
use google_cloud_storage::http::objects::download::Range;
#[tokio::main]
async fn main() {
let client = Client::default().await.unwrap();
let result = client.download_object(&GetObjectRequest{
bucket: "bucket".to_string(),
object: "object".to_string(),
..Default::default()
}, &Range::default(), None).await;
}sourcepub async fn download_streamed_object(
&self,
req: &GetObjectRequest,
range: &Range,
cancel: Option<CancellationToken>
) -> Result<impl Stream<Item = Result<Bytes>>, Error>
pub async fn download_streamed_object(
&self,
req: &GetObjectRequest,
range: &Range,
cancel: Option<CancellationToken>
) -> Result<impl Stream<Item = Result<Bytes>>, Error>
Download the object. https://cloud.google.com/storage/docs/json_api/v1/objects/get alt is always media
use google_cloud_storage::client::Client;
use google_cloud_storage::http::objects::get::GetObjectRequest;
use google_cloud_storage::http::objects::download::Range;
#[tokio::main]
async fn main() {
let client = Client::default().await.unwrap();
let result = client.download_streamed_object(&GetObjectRequest{
bucket: "bucket".to_string(),
object: "object".to_string(),
..Default::default()
}, &Range::default(), None).await;
// while let Some(v) = downloaded.next().await? {
// let d: bytes::Bytes = v.unwrap();
// }
}sourcepub async fn upload_object(
&self,
req: &UploadObjectRequest,
data: &[u8],
content_type: &str,
cancel: Option<CancellationToken>
) -> Result<Object, Error>
pub async fn upload_object(
&self,
req: &UploadObjectRequest,
data: &[u8],
content_type: &str,
cancel: Option<CancellationToken>
) -> Result<Object, Error>
Uploads the object. https://cloud.google.com/storage/docs/json_api/v1/objects/insert ‘uploadType’ is always media - Data-only upload. Upload the object data only, without any metadata.
use google_cloud_storage::client::Client;
use google_cloud_storage::http::objects::upload::UploadObjectRequest;
#[tokio::main]
async fn main() {
let client = Client::default().await.unwrap();
let result = client.upload_object(&UploadObjectRequest{
bucket: "bucket".to_string(),
name: "filename".to_string(),
..Default::default()
}, "hello world".as_bytes(), "application/octet-stream", None).await;
}sourcepub async fn upload_streamed_object<S>(
&self,
req: &UploadObjectRequest,
data: S,
content_type: &str,
content_length: Option<usize>,
cancel: Option<CancellationToken>
) -> Result<Object, Error>where
S: TryStream + Send + Sync + 'static,
S::Error: Into<Box<dyn Error + Send + Sync>>,
Bytes: From<S::Ok>,
pub async fn upload_streamed_object<S>(
&self,
req: &UploadObjectRequest,
data: S,
content_type: &str,
content_length: Option<usize>,
cancel: Option<CancellationToken>
) -> Result<Object, Error>where
S: TryStream + Send + Sync + 'static,
S::Error: Into<Box<dyn Error + Send + Sync>>,
Bytes: From<S::Ok>,
Uploads the streamed object. https://cloud.google.com/storage/docs/json_api/v1/objects/insert ‘uploadType’ is always media - Data-only upload. Upload the object data only, without any metadata.
use google_cloud_storage::client::Client;
use google_cloud_storage::http::objects::upload::UploadObjectRequest;
#[tokio::main]
async fn main() {
let client = Client::default().await.unwrap();
let source = vec!["hello", " ", "world"];
let size = source.iter().map(|x| x.len()).sum();
let chunks: Vec<Result<_, ::std::io::Error>> = source.clone().into_iter().map(|x| Ok(x)).collect();
let stream = futures_util::stream::iter(chunks);
let result = client.upload_streamed_object(&UploadObjectRequest{
bucket: "bucket".to_string(),
name: "filename".to_string(),
..Default::default()
}, stream, "application/octet-stream", Some(size), None).await;
}sourcepub async fn patch_object(
&self,
req: &PatchObjectRequest,
cancel: Option<CancellationToken>
) -> Result<Object, Error>
pub async fn patch_object(
&self,
req: &PatchObjectRequest,
cancel: Option<CancellationToken>
) -> Result<Object, Error>
Patches the object. https://cloud.google.com/storage/docs/json_api/v1/objects/patch
use google_cloud_storage::client::Client;
use google_cloud_storage::http::objects::patch::PatchObjectRequest;
#[tokio::main]
async fn main() {
let client = Client::default().await.unwrap();
let result = client.patch_object(&PatchObjectRequest{
bucket: "bucket".to_string(),
object: "object".to_string(),
..Default::default()
}, None).await;
}sourcepub async fn delete_object(
&self,
req: &DeleteObjectRequest,
cancel: Option<CancellationToken>
) -> Result<(), Error>
pub async fn delete_object(
&self,
req: &DeleteObjectRequest,
cancel: Option<CancellationToken>
) -> Result<(), Error>
Deletes the object. https://cloud.google.com/storage/docs/json_api/v1/objects/delete
use google_cloud_storage::client::Client;
use google_cloud_storage::http::objects::delete::DeleteObjectRequest;
#[tokio::main]
async fn main() {
let client = Client::default().await.unwrap();
let result = client.delete_object(&DeleteObjectRequest{
bucket: "bucket".to_string(),
object: "object".to_string(),
..Default::default()
}, None).await;
}sourcepub async fn rewrite_object(
&self,
req: &RewriteObjectRequest,
cancel: Option<CancellationToken>
) -> Result<RewriteObjectResponse, Error>
pub async fn rewrite_object(
&self,
req: &RewriteObjectRequest,
cancel: Option<CancellationToken>
) -> Result<RewriteObjectResponse, Error>
Rewrites the object. https://cloud.google.com/storage/docs/json_api/v1/objects/rewrite
use google_cloud_storage::client::Client;
use google_cloud_storage::http::objects::rewrite::RewriteObjectRequest;
#[tokio::main]
async fn main() {
let client = Client::default().await.unwrap();
let result = client.rewrite_object(&RewriteObjectRequest{
source_bucket: "bucket1".to_string(),
source_object: "object".to_string(),
destination_bucket: "bucket2".to_string(),
destination_object: "object1".to_string(),
..Default::default()
}, None).await;
}sourcepub async fn compose_object(
&self,
req: &ComposeObjectRequest,
cancel: Option<CancellationToken>
) -> Result<Object, Error>
pub async fn compose_object(
&self,
req: &ComposeObjectRequest,
cancel: Option<CancellationToken>
) -> Result<Object, Error>
Composes the object. https://cloud.google.com/storage/docs/json_api/v1/objects/compose
use google_cloud_storage::client::Client;
use google_cloud_storage::http::objects::compose::{ComposeObjectRequest, ComposingTargets};
use google_cloud_storage::http::objects::rewrite::RewriteObjectRequest;
use google_cloud_storage::http::objects::SourceObjects;
#[tokio::main]
async fn main() {
let client = Client::default().await.unwrap();
let result = client.compose_object(&ComposeObjectRequest{
bucket: "bucket1".to_string(),
destination_object: "object1".to_string(),
composing_targets: ComposingTargets {
source_objects: vec![SourceObjects {
name: "src".to_string(),
..Default::default()
}],
..Default::default()
},
..Default::default()
}, None).await;
}