pub struct Gcs { /* private fields */ }
Expand description
Google Cloud Storage service.
Capabilities
This service can be used to:
- read
- write
- list
- scan
- presign
- blocking
Configuration
root
: Set the work directory for backendbucket
: Set the container name for backendendpoint
: Customizable endpoint settingcredentials
: Credential string for GCS OAuth2
You can refer to GcsBuilder
’s docs for more information
Example
Via Builder
use anyhow::Result;
use opendal::services::Gcs;
use opendal::Operator;
#[tokio::main]
async fn main() -> Result<()> {
// create backend builder
let mut builder = Gcs::default();
// set the storage bucket for OpenDAL
builder.bucket("test");
// set the working directory root for GCS
// all operations will happen within it
builder.root("/path/to/dir");
// set the credentials for GCS OAUTH2 authentication
builder.credential("authentication token");
let op: Operator = Operator::new(builder)?.finish();
Ok(())
}
Implementations§
source§impl GcsBuilder
impl GcsBuilder
sourcepub fn scope(&mut self, scope: &str) -> &mut Self
pub fn scope(&mut self, scope: &str) -> &mut Self
set the GCS service scope
If not set, we will use https://www.googleapis.com/auth/devstorage.read_write
.
Valid scope examples
- read-only:
https://www.googleapis.com/auth/devstorage.read_only
- read-write:
https://www.googleapis.com/auth/devstorage.read_write
- full-control:
https://www.googleapis.com/auth/devstorage.full_control
Reference: Cloud Storage authentication
sourcepub fn service_account(&mut self, service_account: &str) -> &mut Self
pub fn service_account(&mut self, service_account: &str) -> &mut Self
Set the GCS service account.
service account will be used for fetch token from vm metadata.
If not set, we will try to fetch with default
service account.
sourcepub fn credential(&mut self, credential: &str) -> &mut Self
pub fn credential(&mut self, credential: &str) -> &mut Self
set the base64 hashed credentials string used for OAuth2
sourcepub fn credential_path(&mut self, path: &str) -> &mut Self
pub fn credential_path(&mut self, path: &str) -> &mut Self
set the credentials path of GCS.
sourcepub fn http_client(&mut self, client: HttpClient) -> &mut Self
pub fn http_client(&mut self, client: HttpClient) -> &mut Self
Specify the http client that used by this service.
Notes
This API is part of OpenDAL’s Raw API. HttpClient
could be changed
during minor updates.
sourcepub fn signer(&mut self, signer: GoogleSigner) -> &mut Self
pub fn signer(&mut self, signer: GoogleSigner) -> &mut Self
Specify the signer directly instead of building by OpenDAL.
If signer is specified, the following settings will not be used any more:
scope
service_account
credential
credential_path
PLEASE USE THIS API CAREFULLY.
Trait Implementations§
source§impl Builder for GcsBuilder
impl Builder for GcsBuilder
source§impl Clone for GcsBuilder
impl Clone for GcsBuilder
source§fn clone(&self) -> GcsBuilder
fn clone(&self) -> GcsBuilder
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more